How to prevent Jenkins from adding single quotes to parameterized vlaues

6,277 views
Skip to first unread message

no...@gmx.com

unread,
Dec 18, 2015, 4:21:20 PM12/18/15
to Jenkins Users
I basically have a string parameter that contains values from other parameter fields, which I then use again in the Execute shell command.
However, Jenkins adds single quotes in erroneous places within that string, which makes the executing application unable to parse the arguments.

Example:

Name: OPTS Default Value: -e "arg1=${VAR1} arg2=${VAR2} arg3={VAR3}" Execute shell Command: ./build_app $OPTS Console Output: ./build_app -e '"arg1=value1' arg2=value2 'arg3=value3"'

Notice the placement of the single quotes preceding the opening double quote and after value1, and before arg3 and after the closing double quote. These were not added by me.

I have also tried:
Command: ./build_app $(echo $OPTS)

but it renders the same results.

I am trying to figure out if this is expected behavior or if this is an actual bug.
The only other mention of this issue was found here (which went unanswered): http://stackoverflow.com/questions/28260083/how-do-i-prevent-jenkins-from-single-quoting-the-parameterized-value

I am currently running Jenkins 1.642.


Thanks!

no...@gmx.com

unread,
Dec 18, 2015, 4:57:20 PM12/18/15
to Jenkins Users
I've also tried doing this:
Name: OPTS
Default Value: -o tmp -e "arg1=${VAR1} arg2=${VAR2} arg3=${VAR3}"

Execute shell command:
ARGS=$(echo $OPTS)
./build_app $ARGS

Console Output:

++ echo -o tmp -e '"arg1=value1' arg2=value2 'arg3=value3"'
+ ARGS='-o tmp -e "arg1=${VAR1} arg2=${VAR2} arg3={VAR3}"'
+ ./build_app  -o tmp -e '"arg1=value1' arg2=value2 'arg3=value3"'

So it seems the parameter variable itself doesn't contain the single quotes, just when it's being referenced. And the single quotes only appear around wherever there's double quotes in the string.

Daniel Beck

unread,
Dec 18, 2015, 7:58:04 PM12/18/15
to jenkins...@googlegroups.com
I answered this on IRC. Here's basically the same answer again:
http://stackoverflow.com/a/34364786
> --
> You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/ae6da2f1-0391-4f15-97e8-e114734dc1a2%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Aaron G

unread,
Jan 20, 2020, 5:29:33 PM1/20/20
to Jenkins Users
It IS adding the single quotes to build parameters!
> To unsubscribe from this group and stop receiving emails from it, send an email to jenkins...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages