Re: How to load variables from file into windows environment variables in Jenkins pipeline?

2017-01-26 Thread Daniel Beck

> On 26.01.2017, at 15:49, Mark Allison  wrote:
> 
> Thanks, simply using double quotes instead of single works fine.

Unexpected. Looks like I learned something new today. Thanks! 

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/263372A1-A583-410E-A960-8990BA346A21%40beckweb.net.
For more options, visit https://groups.google.com/d/optout.


Re: How to load variables from file into windows environment variables in Jenkins pipeline?

2017-01-26 Thread Mark Allison
Thanks, simply using double quotes instead of single works fine.

bat "echo MYKEY is %MYKEY%"



On Thu, 26 Jan 2017 at 14:25 Daniel Beck  wrote:

>
> > On 26.01.2017, at 12:57, Mark Allison  wrote:
> >
> > How can I load variables from a file in a Windows job and have them
> loaded into the environment at run time?
>
> These are just Groovy variables. You didn't specify for them to be passed
> to launched processes' environment (as e.g. build parameters automatically
> are).
>
> withEnv(…) should work.
>
> env.VAR = 'value' probably too, but am not sure whether that's a
> recommended approach.
>
> --
> 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 jenkinsci-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/32EBB24D-996C-4CE4-8C1B-B1E8ECD6560F%40beckweb.net
> .
> For more options, visit https://groups.google.com/d/optout.
>
-- 

Sent from my phone

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAN9sP2ZjGkjBkC3nDfHTgYX%3D11H%3DjsVDNtaPMkjgzc%3D_bE6DrQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to load variables from file into windows environment variables in Jenkins pipeline?

2017-01-26 Thread Daniel Beck

> On 26.01.2017, at 12:57, Mark Allison  wrote:
> 
> How can I load variables from a file in a Windows job and have them loaded 
> into the environment at run time?

These are just Groovy variables. You didn't specify for them to be passed to 
launched processes' environment (as e.g. build parameters automatically are).

withEnv(…) should work.

env.VAR = 'value' probably too, but am not sure whether that's a recommended 
approach.

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/32EBB24D-996C-4CE4-8C1B-B1E8ECD6560F%40beckweb.net.
For more options, visit https://groups.google.com/d/optout.


How to load variables from file into windows environment variables in Jenkins pipeline?

2017-01-26 Thread Mark Allison
I have the following Jenkinsfile

node  {
stage 'checkout'
deleteDir()
checkout scm

load 'LoadTheseVariables.txt'  

echo "MYKEY: ${MYKEY}"
echo "REPO: ${REPO}"

bat 'echo MYKEY is %MYKEY%'
bat 'echo REPO is %REPO%'
}


The file *LoadTheseVariables.txt* contains:

MYKEY="ThisIsTheKey"
REPO="ThisIsTheRepo"


The output of the Jenkins build is:

<..snip..>
[Pipeline] load
[Pipeline] { (LoadTheseVariables.txt)
[Pipeline] }
[Pipeline] // load
[Pipeline] echo
MYKEY: ThisIsTheKey
[Pipeline] echo
REPO: ThisIsTheRepo
[Pipeline] bat
[test] Running batch script

D:\Jenkins\workspace\test>echo MYKEY is  
MYKEY is 
[Pipeline] bat
[test] Running batch script

D:\Jenkins\workspace\test>echo REPO is  
REPO is 
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS


The Jenkins pipeline can see the variables but why can't my windows cmd 
environment see the variables? I even tried this step before the `bat` 
commands at the end: `bat 'refreshenv'` but that didn't reload the 
environment with those variables.

How can I load variables from a file in a Windows job and have them loaded 
into the environment at run time?

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/8dd050be-24cb-47ab-a3bb-4ff4ac88f0c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.