Georg Heiler Georg Heiler - 2 months ago 53
Bash Question

Jenkins workflow pass variable to shell script

How can I pass a variable e.g.

buildNumber


sh 'gulp sometask --someOption="attribute=${env.BUILD_NUMBER}"'


to the
sh
command using Jenkins workflow / pipeline?
My example unfortunately only yields a bad substitution error.

Answer

could you please try this command here:

sh "gulp sometask --someOption='attribute=${env.BUILD_NUMBER}'"

The quotation marks are exchanged. I think the reason is, that you can templating with double quotes (using GString), which doesn't work with single quotes (using a plain String) in groovy.

for more information see the Groovy Documentation

Comments