jenkinsfile not passing env to shHow do I make Jenkins 2.0 execute a sh command in the same directory as the checkout?Get git branch name in Jenkins Pipeline/JenkinsfileJenkinsfile error- java.lang.NoSuchMethodError: No such DSL method 'withMaven' found among stepsWhere is jenkinsfile downloaded when job fetches pipeline script from SCMJenkins Pipeline “yarn install” command not foundcan not create file via Groovy code(or java code) in jenkinsfile of a pipeline job on Jenkinshow to fix npm: not found errorSed command not working in Jenkins PipelineJenkins pipeline fails with bad substitution error on file readAzure login with Jenkins pipeline
In the UK, is it possible to get a referendum by a court decision?
What exactly is ineptocracy?
What is an equivalently powerful replacement spell for the Yuan-Ti's Suggestion spell?
Getting extremely large arrows with tikzcd
How do conventional missiles fly?
Why are UK visa biometrics appointments suspended at USCIS Application Support Centers?
Does Dispel Magic work on Tiny Hut?
Sums of two squares in arithmetic progressions
Are British MPs missing the point, with these 'Indicative Votes'?
How to show a landlord what we have in savings?
how do we prove that a sum of two periods is still a period?
How to find if SQL server backup is encrypted with TDE without restoring the backup
Should I tell management that I intend to leave due to bad software development practices?
What does the same-ish mean?
Could the museum Saturn V's be refitted for one more flight?
What reasons are there for a Capitalist to oppose a 100% inheritance tax?
How does a refinance allow a mortgage to be repaid?
Placement of More Information/Help Icon button for Radio Buttons
GFCI outlets - can they be repaired? Are they really needed at the end of a circuit?
Send out email when Apex Queueable fails and test it
Implication of namely
Knowledge-based authentication using Domain-driven Design in C#
Car headlights in a world without electricity
What's the meaning of "Sollensaussagen"?
jenkinsfile not passing env to sh
How do I make Jenkins 2.0 execute a sh command in the same directory as the checkout?Get git branch name in Jenkins Pipeline/JenkinsfileJenkinsfile error- java.lang.NoSuchMethodError: No such DSL method 'withMaven' found among stepsWhere is jenkinsfile downloaded when job fetches pipeline script from SCMJenkins Pipeline “yarn install” command not foundcan not create file via Groovy code(or java code) in jenkinsfile of a pipeline job on Jenkinshow to fix npm: not found errorSed command not working in Jenkins PipelineJenkins pipeline fails with bad substitution error on file readAzure login with Jenkins pipeline
I am trying to set environment variable in Jenkinsfile following way,
pipeline
agent label 'slave1'
stages
stage ('Build')
steps
script
BUILD_VERSION = sh (
script: 'python get_firmware_version.py',
returnStdout: true
).trim()
echo "$BUILD_VERSION"
withCredentials([file(credentialsId: 'image-sign', variable: 'IMAGE_SIGN')])
dir('firmware/')
echo "$BUILD_VERSION"
sh '''
echo "Building"
echo "$BUILD_VERSION"
echo "$env.BUILD_VERSION"
'''
post
failure
script
echo "Pipeline Failed"
But its failing with following error Bad substitution
[Pipeline] echo
0_2_0
[Pipeline] sh
+ echo Building
Building
/home/jenkins/jenkins_slave/workspace/Firmware/Branch/firmware@tmp/durable-54e04481/script.sh: 3: /home/jenkins/jenkins_slave/workspace/Firmware/Branch/firmware@tmp/durable-54e04481/script.sh: Bad substitution
Why I can't set ENV Var and use it in sh step ?
jenkins jenkins-pipeline
add a comment |
I am trying to set environment variable in Jenkinsfile following way,
pipeline
agent label 'slave1'
stages
stage ('Build')
steps
script
BUILD_VERSION = sh (
script: 'python get_firmware_version.py',
returnStdout: true
).trim()
echo "$BUILD_VERSION"
withCredentials([file(credentialsId: 'image-sign', variable: 'IMAGE_SIGN')])
dir('firmware/')
echo "$BUILD_VERSION"
sh '''
echo "Building"
echo "$BUILD_VERSION"
echo "$env.BUILD_VERSION"
'''
post
failure
script
echo "Pipeline Failed"
But its failing with following error Bad substitution
[Pipeline] echo
0_2_0
[Pipeline] sh
+ echo Building
Building
/home/jenkins/jenkins_slave/workspace/Firmware/Branch/firmware@tmp/durable-54e04481/script.sh: 3: /home/jenkins/jenkins_slave/workspace/Firmware/Branch/firmware@tmp/durable-54e04481/script.sh: Bad substitution
Why I can't set ENV Var and use it in sh step ?
jenkins jenkins-pipeline
Inside the shell the syntax to access env vars is $BUILD_VERSION.
– Brian Walker
Mar 8 at 21:12
echo $BUILD_VERSION
prints empty insh
– roy
Mar 8 at 21:16
Because that is incorrect syntax in sh. Just useecho $BUILD_VERSION
in the shell section. The syntax in Jenkinsfile and the syntax in a shell script are different for accessing environment variables.
– Brian Walker
Mar 8 at 21:32
echo $BUILD_VERSION
prints empty insh
– roy
Mar 8 at 21:39
add a comment |
I am trying to set environment variable in Jenkinsfile following way,
pipeline
agent label 'slave1'
stages
stage ('Build')
steps
script
BUILD_VERSION = sh (
script: 'python get_firmware_version.py',
returnStdout: true
).trim()
echo "$BUILD_VERSION"
withCredentials([file(credentialsId: 'image-sign', variable: 'IMAGE_SIGN')])
dir('firmware/')
echo "$BUILD_VERSION"
sh '''
echo "Building"
echo "$BUILD_VERSION"
echo "$env.BUILD_VERSION"
'''
post
failure
script
echo "Pipeline Failed"
But its failing with following error Bad substitution
[Pipeline] echo
0_2_0
[Pipeline] sh
+ echo Building
Building
/home/jenkins/jenkins_slave/workspace/Firmware/Branch/firmware@tmp/durable-54e04481/script.sh: 3: /home/jenkins/jenkins_slave/workspace/Firmware/Branch/firmware@tmp/durable-54e04481/script.sh: Bad substitution
Why I can't set ENV Var and use it in sh step ?
jenkins jenkins-pipeline
I am trying to set environment variable in Jenkinsfile following way,
pipeline
agent label 'slave1'
stages
stage ('Build')
steps
script
BUILD_VERSION = sh (
script: 'python get_firmware_version.py',
returnStdout: true
).trim()
echo "$BUILD_VERSION"
withCredentials([file(credentialsId: 'image-sign', variable: 'IMAGE_SIGN')])
dir('firmware/')
echo "$BUILD_VERSION"
sh '''
echo "Building"
echo "$BUILD_VERSION"
echo "$env.BUILD_VERSION"
'''
post
failure
script
echo "Pipeline Failed"
But its failing with following error Bad substitution
[Pipeline] echo
0_2_0
[Pipeline] sh
+ echo Building
Building
/home/jenkins/jenkins_slave/workspace/Firmware/Branch/firmware@tmp/durable-54e04481/script.sh: 3: /home/jenkins/jenkins_slave/workspace/Firmware/Branch/firmware@tmp/durable-54e04481/script.sh: Bad substitution
Why I can't set ENV Var and use it in sh step ?
jenkins jenkins-pipeline
jenkins jenkins-pipeline
asked Mar 8 at 21:09
royroy
1,36863078
1,36863078
Inside the shell the syntax to access env vars is $BUILD_VERSION.
– Brian Walker
Mar 8 at 21:12
echo $BUILD_VERSION
prints empty insh
– roy
Mar 8 at 21:16
Because that is incorrect syntax in sh. Just useecho $BUILD_VERSION
in the shell section. The syntax in Jenkinsfile and the syntax in a shell script are different for accessing environment variables.
– Brian Walker
Mar 8 at 21:32
echo $BUILD_VERSION
prints empty insh
– roy
Mar 8 at 21:39
add a comment |
Inside the shell the syntax to access env vars is $BUILD_VERSION.
– Brian Walker
Mar 8 at 21:12
echo $BUILD_VERSION
prints empty insh
– roy
Mar 8 at 21:16
Because that is incorrect syntax in sh. Just useecho $BUILD_VERSION
in the shell section. The syntax in Jenkinsfile and the syntax in a shell script are different for accessing environment variables.
– Brian Walker
Mar 8 at 21:32
echo $BUILD_VERSION
prints empty insh
– roy
Mar 8 at 21:39
Inside the shell the syntax to access env vars is $BUILD_VERSION.
– Brian Walker
Mar 8 at 21:12
Inside the shell the syntax to access env vars is $BUILD_VERSION.
– Brian Walker
Mar 8 at 21:12
echo $BUILD_VERSION
prints empty in sh
– roy
Mar 8 at 21:16
echo $BUILD_VERSION
prints empty in sh
– roy
Mar 8 at 21:16
Because that is incorrect syntax in sh. Just use
echo $BUILD_VERSION
in the shell section. The syntax in Jenkinsfile and the syntax in a shell script are different for accessing environment variables.– Brian Walker
Mar 8 at 21:32
Because that is incorrect syntax in sh. Just use
echo $BUILD_VERSION
in the shell section. The syntax in Jenkinsfile and the syntax in a shell script are different for accessing environment variables.– Brian Walker
Mar 8 at 21:32
echo $BUILD_VERSION
prints empty in sh
– roy
Mar 8 at 21:39
echo $BUILD_VERSION
prints empty in sh
– roy
Mar 8 at 21:39
add a comment |
1 Answer
1
active
oldest
votes
This is Jenkins thing I think. When you use the sh
block with '
; it will not have access to things like environment variables. Try using the "
instead. That should work
sh """
echo "Building"
echo "$env.BUILD_VERSION"
echo "$env"
"""
Jenkins should recognise the shell block and escape the "
within the """
automatically.
pipeline
agent label 'slave1'
stages
stage ('Build')
steps
script
BUILD_VERSION = sh (
script: 'python get_firmware_version.py',
returnStdout: true
).trim()
echo "$BUILD_VERSION"
withCredentials([file(credentialsId: 'image-sign', variable: 'IMAGE_SIGN')])
dir('firmware/')
echo "$BUILD_VERSION"
sh """
echo "Building"
echo "$BUILD_VERSION"
echo "$env.BUILD_VERSION"
"""
post
failure
script
echo "Pipeline Failed"
My test case
pipeline
agent
node
label 'devops-jenkins-slave'
options
timestamps()
stages
stage('Setup')
steps
dir("$WORKSPACE/")
script
BUILD_VERSION = "1"
sh """
echo "$BUILD_VERSION"
"""
post
always
dir("$WORKSPACE/")
deleteDir()
Result
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on devops-jenkins-slave in /home/jenkins/workspace/Samples/Test
[Pipeline]
[Pipeline] timestamps
[Pipeline]
[Pipeline] stage
[Pipeline] (Setup)
[Pipeline] dir
22:09:55 Running in /home/jenkins/workspace/Samples/Test
[Pipeline]
[Pipeline] script
[Pipeline]
[Pipeline]
[Pipeline] // script
[Pipeline] sh
22:09:56 [Test] Running shell script
22:09:56 + echo 1
22:09:56 1
[Pipeline]
[Pipeline] // dir
[Pipeline]
[Pipeline] // stage
[Pipeline] stage
[Pipeline] (Declarative: Post Actions)
[Pipeline] dir
22:09:56 Running in /home/jenkins/workspace/Samples/Test
[Pipeline]
[Pipeline] deleteDir
[Pipeline]
[Pipeline] // dir
[Pipeline]
[Pipeline] // stage
[Pipeline]
[Pipeline] // timestamps
[Pipeline]
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
illegal string character after dollar sign
got for this change
– roy
Mar 8 at 22:04
Sorry, my fault. Try deletingecho "$env.BUILD_VERSION"
?
– Praveen Premaratne
Mar 8 at 22:11
Do you have a line reff of the offending line?
– Praveen Premaratne
Mar 8 at 22:12
1
nevermind, it worked.
– roy
Mar 8 at 22:14
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55071024%2fjenkinsfile-not-passing-env-to-sh%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This is Jenkins thing I think. When you use the sh
block with '
; it will not have access to things like environment variables. Try using the "
instead. That should work
sh """
echo "Building"
echo "$env.BUILD_VERSION"
echo "$env"
"""
Jenkins should recognise the shell block and escape the "
within the """
automatically.
pipeline
agent label 'slave1'
stages
stage ('Build')
steps
script
BUILD_VERSION = sh (
script: 'python get_firmware_version.py',
returnStdout: true
).trim()
echo "$BUILD_VERSION"
withCredentials([file(credentialsId: 'image-sign', variable: 'IMAGE_SIGN')])
dir('firmware/')
echo "$BUILD_VERSION"
sh """
echo "Building"
echo "$BUILD_VERSION"
echo "$env.BUILD_VERSION"
"""
post
failure
script
echo "Pipeline Failed"
My test case
pipeline
agent
node
label 'devops-jenkins-slave'
options
timestamps()
stages
stage('Setup')
steps
dir("$WORKSPACE/")
script
BUILD_VERSION = "1"
sh """
echo "$BUILD_VERSION"
"""
post
always
dir("$WORKSPACE/")
deleteDir()
Result
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on devops-jenkins-slave in /home/jenkins/workspace/Samples/Test
[Pipeline]
[Pipeline] timestamps
[Pipeline]
[Pipeline] stage
[Pipeline] (Setup)
[Pipeline] dir
22:09:55 Running in /home/jenkins/workspace/Samples/Test
[Pipeline]
[Pipeline] script
[Pipeline]
[Pipeline]
[Pipeline] // script
[Pipeline] sh
22:09:56 [Test] Running shell script
22:09:56 + echo 1
22:09:56 1
[Pipeline]
[Pipeline] // dir
[Pipeline]
[Pipeline] // stage
[Pipeline] stage
[Pipeline] (Declarative: Post Actions)
[Pipeline] dir
22:09:56 Running in /home/jenkins/workspace/Samples/Test
[Pipeline]
[Pipeline] deleteDir
[Pipeline]
[Pipeline] // dir
[Pipeline]
[Pipeline] // stage
[Pipeline]
[Pipeline] // timestamps
[Pipeline]
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
illegal string character after dollar sign
got for this change
– roy
Mar 8 at 22:04
Sorry, my fault. Try deletingecho "$env.BUILD_VERSION"
?
– Praveen Premaratne
Mar 8 at 22:11
Do you have a line reff of the offending line?
– Praveen Premaratne
Mar 8 at 22:12
1
nevermind, it worked.
– roy
Mar 8 at 22:14
add a comment |
This is Jenkins thing I think. When you use the sh
block with '
; it will not have access to things like environment variables. Try using the "
instead. That should work
sh """
echo "Building"
echo "$env.BUILD_VERSION"
echo "$env"
"""
Jenkins should recognise the shell block and escape the "
within the """
automatically.
pipeline
agent label 'slave1'
stages
stage ('Build')
steps
script
BUILD_VERSION = sh (
script: 'python get_firmware_version.py',
returnStdout: true
).trim()
echo "$BUILD_VERSION"
withCredentials([file(credentialsId: 'image-sign', variable: 'IMAGE_SIGN')])
dir('firmware/')
echo "$BUILD_VERSION"
sh """
echo "Building"
echo "$BUILD_VERSION"
echo "$env.BUILD_VERSION"
"""
post
failure
script
echo "Pipeline Failed"
My test case
pipeline
agent
node
label 'devops-jenkins-slave'
options
timestamps()
stages
stage('Setup')
steps
dir("$WORKSPACE/")
script
BUILD_VERSION = "1"
sh """
echo "$BUILD_VERSION"
"""
post
always
dir("$WORKSPACE/")
deleteDir()
Result
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on devops-jenkins-slave in /home/jenkins/workspace/Samples/Test
[Pipeline]
[Pipeline] timestamps
[Pipeline]
[Pipeline] stage
[Pipeline] (Setup)
[Pipeline] dir
22:09:55 Running in /home/jenkins/workspace/Samples/Test
[Pipeline]
[Pipeline] script
[Pipeline]
[Pipeline]
[Pipeline] // script
[Pipeline] sh
22:09:56 [Test] Running shell script
22:09:56 + echo 1
22:09:56 1
[Pipeline]
[Pipeline] // dir
[Pipeline]
[Pipeline] // stage
[Pipeline] stage
[Pipeline] (Declarative: Post Actions)
[Pipeline] dir
22:09:56 Running in /home/jenkins/workspace/Samples/Test
[Pipeline]
[Pipeline] deleteDir
[Pipeline]
[Pipeline] // dir
[Pipeline]
[Pipeline] // stage
[Pipeline]
[Pipeline] // timestamps
[Pipeline]
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
illegal string character after dollar sign
got for this change
– roy
Mar 8 at 22:04
Sorry, my fault. Try deletingecho "$env.BUILD_VERSION"
?
– Praveen Premaratne
Mar 8 at 22:11
Do you have a line reff of the offending line?
– Praveen Premaratne
Mar 8 at 22:12
1
nevermind, it worked.
– roy
Mar 8 at 22:14
add a comment |
This is Jenkins thing I think. When you use the sh
block with '
; it will not have access to things like environment variables. Try using the "
instead. That should work
sh """
echo "Building"
echo "$env.BUILD_VERSION"
echo "$env"
"""
Jenkins should recognise the shell block and escape the "
within the """
automatically.
pipeline
agent label 'slave1'
stages
stage ('Build')
steps
script
BUILD_VERSION = sh (
script: 'python get_firmware_version.py',
returnStdout: true
).trim()
echo "$BUILD_VERSION"
withCredentials([file(credentialsId: 'image-sign', variable: 'IMAGE_SIGN')])
dir('firmware/')
echo "$BUILD_VERSION"
sh """
echo "Building"
echo "$BUILD_VERSION"
echo "$env.BUILD_VERSION"
"""
post
failure
script
echo "Pipeline Failed"
My test case
pipeline
agent
node
label 'devops-jenkins-slave'
options
timestamps()
stages
stage('Setup')
steps
dir("$WORKSPACE/")
script
BUILD_VERSION = "1"
sh """
echo "$BUILD_VERSION"
"""
post
always
dir("$WORKSPACE/")
deleteDir()
Result
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on devops-jenkins-slave in /home/jenkins/workspace/Samples/Test
[Pipeline]
[Pipeline] timestamps
[Pipeline]
[Pipeline] stage
[Pipeline] (Setup)
[Pipeline] dir
22:09:55 Running in /home/jenkins/workspace/Samples/Test
[Pipeline]
[Pipeline] script
[Pipeline]
[Pipeline]
[Pipeline] // script
[Pipeline] sh
22:09:56 [Test] Running shell script
22:09:56 + echo 1
22:09:56 1
[Pipeline]
[Pipeline] // dir
[Pipeline]
[Pipeline] // stage
[Pipeline] stage
[Pipeline] (Declarative: Post Actions)
[Pipeline] dir
22:09:56 Running in /home/jenkins/workspace/Samples/Test
[Pipeline]
[Pipeline] deleteDir
[Pipeline]
[Pipeline] // dir
[Pipeline]
[Pipeline] // stage
[Pipeline]
[Pipeline] // timestamps
[Pipeline]
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
This is Jenkins thing I think. When you use the sh
block with '
; it will not have access to things like environment variables. Try using the "
instead. That should work
sh """
echo "Building"
echo "$env.BUILD_VERSION"
echo "$env"
"""
Jenkins should recognise the shell block and escape the "
within the """
automatically.
pipeline
agent label 'slave1'
stages
stage ('Build')
steps
script
BUILD_VERSION = sh (
script: 'python get_firmware_version.py',
returnStdout: true
).trim()
echo "$BUILD_VERSION"
withCredentials([file(credentialsId: 'image-sign', variable: 'IMAGE_SIGN')])
dir('firmware/')
echo "$BUILD_VERSION"
sh """
echo "Building"
echo "$BUILD_VERSION"
echo "$env.BUILD_VERSION"
"""
post
failure
script
echo "Pipeline Failed"
My test case
pipeline
agent
node
label 'devops-jenkins-slave'
options
timestamps()
stages
stage('Setup')
steps
dir("$WORKSPACE/")
script
BUILD_VERSION = "1"
sh """
echo "$BUILD_VERSION"
"""
post
always
dir("$WORKSPACE/")
deleteDir()
Result
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on devops-jenkins-slave in /home/jenkins/workspace/Samples/Test
[Pipeline]
[Pipeline] timestamps
[Pipeline]
[Pipeline] stage
[Pipeline] (Setup)
[Pipeline] dir
22:09:55 Running in /home/jenkins/workspace/Samples/Test
[Pipeline]
[Pipeline] script
[Pipeline]
[Pipeline]
[Pipeline] // script
[Pipeline] sh
22:09:56 [Test] Running shell script
22:09:56 + echo 1
22:09:56 1
[Pipeline]
[Pipeline] // dir
[Pipeline]
[Pipeline] // stage
[Pipeline] stage
[Pipeline] (Declarative: Post Actions)
[Pipeline] dir
22:09:56 Running in /home/jenkins/workspace/Samples/Test
[Pipeline]
[Pipeline] deleteDir
[Pipeline]
[Pipeline] // dir
[Pipeline]
[Pipeline] // stage
[Pipeline]
[Pipeline] // timestamps
[Pipeline]
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
edited Mar 8 at 22:14
answered Mar 8 at 21:52
Praveen PremaratnePraveen Premaratne
1,4421718
1,4421718
illegal string character after dollar sign
got for this change
– roy
Mar 8 at 22:04
Sorry, my fault. Try deletingecho "$env.BUILD_VERSION"
?
– Praveen Premaratne
Mar 8 at 22:11
Do you have a line reff of the offending line?
– Praveen Premaratne
Mar 8 at 22:12
1
nevermind, it worked.
– roy
Mar 8 at 22:14
add a comment |
illegal string character after dollar sign
got for this change
– roy
Mar 8 at 22:04
Sorry, my fault. Try deletingecho "$env.BUILD_VERSION"
?
– Praveen Premaratne
Mar 8 at 22:11
Do you have a line reff of the offending line?
– Praveen Premaratne
Mar 8 at 22:12
1
nevermind, it worked.
– roy
Mar 8 at 22:14
illegal string character after dollar sign
got for this change– roy
Mar 8 at 22:04
illegal string character after dollar sign
got for this change– roy
Mar 8 at 22:04
Sorry, my fault. Try deleting
echo "$env.BUILD_VERSION"
?– Praveen Premaratne
Mar 8 at 22:11
Sorry, my fault. Try deleting
echo "$env.BUILD_VERSION"
?– Praveen Premaratne
Mar 8 at 22:11
Do you have a line reff of the offending line?
– Praveen Premaratne
Mar 8 at 22:12
Do you have a line reff of the offending line?
– Praveen Premaratne
Mar 8 at 22:12
1
1
nevermind, it worked.
– roy
Mar 8 at 22:14
nevermind, it worked.
– roy
Mar 8 at 22:14
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55071024%2fjenkinsfile-not-passing-env-to-sh%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Inside the shell the syntax to access env vars is $BUILD_VERSION.
– Brian Walker
Mar 8 at 21:12
echo $BUILD_VERSION
prints empty insh
– roy
Mar 8 at 21:16
Because that is incorrect syntax in sh. Just use
echo $BUILD_VERSION
in the shell section. The syntax in Jenkinsfile and the syntax in a shell script are different for accessing environment variables.– Brian Walker
Mar 8 at 21:32
echo $BUILD_VERSION
prints empty insh
– roy
Mar 8 at 21:39