Reputation: 81
For a freestyle job, I have a bash script that is run using shell command as the build step. This script takes in a choice parameter as an argument and this works well when configuring the job via the GUI like so:
/path/to/script ${CHOICE_PARAMETER_VALUE}
However, when I am using job DSL to configure this job, I am using the "shell" function in the steps block but cannot pass an argument to it successfully. This is what I tried:
shell(readFileFromWorkspace('build.sh') ${CHOICE_PARAMETER_VALUE})
Is there a way to pass Jenkins variables as shell arguments in job DSL?
Upvotes: 1
Views: 3622
Reputation: 81
I have just asked a colleague and apparently, there is no need to do what I was intending to do. Jenkins environment variables (and parameters) can be referenced by the called shell script, hence there is no need to specifically pass the parameters/variables as arguments.
Basically, I can do this in my build.sh
script:
echo ${CHOICE_PARAMETER_VALUE}
I have tested this and it works fine!!!
Upvotes: 2