Georg Heiler Georg Heiler - 1 year ago 290
Bash Question

Jenkins workflow pass variable to shell script

How can I pass a variable e.g.


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

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

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download