Environment variable - shell

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Environment variable - shell

Elango Thiagarajan
Hi folks,

I am very new to Jenkins. Kindly help me through.

I have few parameters declared in my pipeline script and i need to pass that to environment  variables. 

i tried like below

sh """
     export GOOL=${params.GOOL}

but while execution is throwing bad substitution exception. Any pointers on what wrong here


The exported enviornmnet variable will be used as input to run a docker image.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/82ce9f00-434d-4a99-8e70-0233fecde1f6n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

RE: Environment variable - shell

Jheison Rodriguez

Correct if I’m wrong guys, but I think you should skip the $ for \$

 

 

 

Jheison Rodriguez

 

From: [hidden email]
Sent: Tuesday, February 2, 2021 10:58 AM
To: [hidden email]
Subject: Environment variable - shell

 

Hi folks,

 

I am very new to Jenkins. Kindly help me through.

 

I have few parameters declared in my pipeline script and i need to pass that to environment  variables. 

 

i tried like below

 

sh """

     export GOOL=${params.GOOL}

 

but while execution is throwing bad substitution exception. Any pointers on what wrong here

 

 

The exported enviornmnet variable will be used as input to run a docker image.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/82ce9f00-434d-4a99-8e70-0233fecde1f6n%40googlegroups.com.

 

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/915D9468-E105-49A6-9D5E-01B1C24CF693%40hxcore.ol.
Reply | Threaded
Open this post in threaded view
|

RE: Environment variable - shell

Gianluca
In reply to this post by Elango Thiagarajan

Hi,

Jenkins does it for you if you use the “environment” block.

 

https://www.jenkins.io/doc/book/pipeline/syntax/#environment

 

There is an example that uses “sh” command to show how Jenkins automatically inject environment variable inside a shell.

 

Cheers,

Gianluca.

 

 

From: [hidden email] <[hidden email]> On Behalf Of Elango Thiagarajan
Sent: 02 February 2021 15:23
To: Jenkins Users <[hidden email]>
Subject: Environment variable - shell

 

Hi folks,

 

I am very new to Jenkins. Kindly help me through.

 

I have few parameters declared in my pipeline script and i need to pass that to environment  variables. 

 

i tried like below

 

sh """

     export GOOL=${params.GOOL}

 

but while execution is throwing bad substitution exception. Any pointers on what wrong here

 

 

The exported enviornmnet variable will be used as input to run a docker image.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/82ce9f00-434d-4a99-8e70-0233fecde1f6n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/028a01d6f97e%24e9f9b520%24bded1f60%24%40gmail.com.
Reply | Threaded
Open this post in threaded view
|

RE: Environment variable - shell

Jérôme Godbout
In reply to this post by Elango Thiagarajan

Can you use

withEnv([“GOOL =${params.GOOL”}]) {

   sh(…);

}

 

Jérôme Godbout
Software / Firmware Lead

C: (581) 777-0050 
O: (418) 800-1073 ext.: 109  
[hidden email]

dimonoff.com   |    amotus.ca

 

From: [hidden email] <[hidden email]> On Behalf Of Elango Thiagarajan
Sent: February 2, 2021 10:23 AM
To: Jenkins Users <[hidden email]>
Subject: Environment variable - shell

 

Hi folks,

 

I am very new to Jenkins. Kindly help me through.

 

I have few parameters declared in my pipeline script and i need to pass that to environment  variables. 

 

i tried like below

 

sh """

     export GOOL=${params.GOOL}

 

but while execution is throwing bad substitution exception. Any pointers on what wrong here

 

 

The exported enviornmnet variable will be used as input to run a docker image.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/82ce9f00-434d-4a99-8e70-0233fecde1f6n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/QB1PR01MB384434357DD5A58A3890A569CDB59%40QB1PR01MB3844.CANPRD01.PROD.OUTLOOK.COM.
Reply | Threaded
Open this post in threaded view
|

Re: Environment variable - shell

Elango Thiagarajan
Thanks  Jerome. It worked perfectly.

On Wednesday, 3 February 2021 at 00:54:04 UTC+8 Jérôme Godbout wrote:

Can you use

withEnv([“GOOL =${params.GOOL”}]) {

   sh(…);

}

 

Jérôme Godbout
Software / Firmware Lead

C: <a href="tel:(581)%20777-0050" value="+15817770050" target="_blank" rel="nofollow">(581) 777-0050 
O: <a href="tel:(418)%20800-1073" value="+14188001073" target="_blank" rel="nofollow">(418) 800-1073 ext.: 109  
[hidden email]

dimonoff.com   |    amotus.ca

 

From: [hidden email] <[hidden email]> On Behalf Of Elango Thiagarajan
Sent: February 2, 2021 10:23 AM
To: Jenkins Users <[hidden email]>
Subject: Environment variable - shell

 

Hi folks,

 

I am very new to Jenkins. Kindly help me through.

 

I have few parameters declared in my pipeline script and i need to pass that to environment  variables. 

 

i tried like below

 

sh """

     export GOOL=${params.GOOL}

 

but while execution is throwing bad substitution exception. Any pointers on what wrong here

 

 

The exported enviornmnet variable will be used as input to run a docker image.

--

You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/82ce9f00-434d-4a99-8e70-0233fecde1f6n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/97bcb7dc-52f5-44a7-af2d-f07c7f6d10b0n%40googlegroups.com.