Inline Bash script in shell()

440 wyświetleń
Przejdź do pierwszej nieodczytanej wiadomości

Misty Stanley-Jones

nieprzeczytany,
16 kwi 2015, 19:49:4016.04.2015
do job-dsl...@googlegroups.com
Hi all,

I confess I do not know about Groovy at all and have been trying to develop a job DSL by trial and error. I have a seed job that takes parameters, and then kicks off the DSL. I have the variable substitutions working fine, except within the actual shell() clause. What I have is like this:

The environment variables are set like
Build_Object=master
HTML_Map=administration.ditamap
Toolchain=d4p

The shell clause is like this, inside the job definition:

shell('''
#!/bin/bash
./jenkins_build_docs.sh -b ${Build_Object} $FILTER -m ${HTML_Map} -t ${Toolchain}
'''

But within the generated job, the shell script looks like this:

#!/bin/bash
./jenkins_build_docs.sh -b ${Build_Object} -m ${HTML_Map} -t ${Toolchain}

I expect it to look like this:

#!/bin/bash
./jenkins_build_docs.sh -b master -m administration.ditamap -t d4p

Does anybody have any idea about the (probably really silly) thing I am doing wrong?

Misty Stanley-Jones

nieprzeczytany,
16 kwi 2015, 19:51:3116.04.2015
do job-dsl...@googlegroups.com


On Friday, April 17, 2015 at 9:49:40 AM UTC+10, Misty Stanley-Jones wrote:

The shell clause is like this, inside the job definition:

shell('''
#!/bin/bash
./jenkins_build_docs.sh -b ${Build_Object} $FILTER -m ${HTML_Map} -t ${Toolchain}
'''


When pasting into the email, I missed the closing ), but it is there in the script.
 

Marshall Pierce

nieprzeczytany,
16 kwi 2015, 19:55:1416.04.2015
do job-dsl...@googlegroups.com
Try using """ instead of '''. 

-Marshall

Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "job-dsl-plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to job-dsl-plugi...@googlegroups.com.
To post to this group, send email to job-dsl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/job-dsl-plugin/9e1a3736-38e0-4fca-a2fd-c22ea2533d5c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Misty Stanley-Jones

nieprzeczytany,
16 kwi 2015, 20:03:4216.04.2015
do job-dsl...@googlegroups.com
That worked great! I did discover that if I had a Bash variable in the shell() (such as $DRAFT), I would have to escape the $ from it like \$DRAFT. This is awesome and means I am 99% of the way to having my DSL working correctly. Thanks so much for your help!
Odpowiedz wszystkim
Odpowiedz autorowi
Przekaż
Nowe wiadomości: 0