How to pass a multiline parameter to jenkins cli build

5,673 views
Skip to first unread message

Denis Gaudet

unread,
Dec 11, 2015, 5:15:07 PM12/11/15
to Jenkins Users
Hey folks,

I'm trying to pass a multiline parameter to a build from a BASH command
line. My command looks like this:

/java -jar ~/files/jenkins-cli.jar -s http://<my jenkins url>  build -s
'Fundamental/math-flex' -p DESCRIPTION="$mydesc" -p
configspec_elements="$mycs"/

I have exported both variables as:

/export mydesc='Dry run'
export mycs='element /reuse /main/LATEST\nelement /reuse/ip /main/LATEST'/

When this gets into the jenkins job, the $mycs looks like this:

/element /reuse /main/LATEST\nelement /reuse/ip /main/LATEST/

I was hoping/expecting the "\n" to have been expanded, but, it wasn't ;(

How else can I get multiple lines trough the CLI interface?

Thanks in advance for your help!

Denis

DGaudet

unread,
Dec 14, 2015, 2:12:25 PM12/14/15
to Jenkins Users
I have identified a solution that works :)

When exporting the env variable, hit the enter key on the command line and keep adding lines and then close the quotes on the least line. This would look like the following:

prompt:> export mycs='element /reuse /main/LATEST
> element /reuse/ip /main/LATEST
> element /reuse/ip/file.txt /main/LATEST'

Then, test it out using echo with double quotes around the variable as:

echo "$mycs"

Once formatted as wanted, simply pass in the variable to the Jenkins CLI to be used on the other side like this:

java -jar ~/files/jenkins-cli.jar -s http://<my jenkins url>  build -s 'Fundamental/math-flex' -p DESCRIPTION="$mydesc" -p configspec_elements="$mycs"

Hope this helps\you as much as it helped me :)

Denis
Reply all
Reply to author
Forward
0 new messages