Hi all, I solved my problem by doing shell interpolation at the previous stages with proper shell escaping and breaking the steps into smaller ones The below sample code works
sh"""#!/usr/bin/env bash /usr/bin/sudo -iu user cleartool setview -exec 'clearmake -k full' "${env.VIEW}" | awk -F '<|>' 'NR ==3 { print \$2 }' > build.txt """ Thanks and have a great time. На вт, 18.02.2020 г. в 11:03 Dimitar Vassilev <dimitar.vassi...@gmail.com> написа: > Hi Chris, > > Clearmake is a part of ClearCase SCM and it's a COTS binary. I'm > attemping to inject a build in the ClearCase build farm , get the build id > and restart the build 3 times if it fails the first time. > > The correct commands in the pipeline are > > stage('inject full build'){ > steps{ > script { > sh "#!/usr/bin/env bash \n" + > "cleartool setview -exec 'clearmake -k full' ${VIEW} | awk -F > '<|>' 'NR ==2 { print $2 } ' > foo.txt" > } > } > } > > Overall I will test again with """ """ which means to interpolate stuff > inside to the best of my knowledge. For the time being I will open myself a > drink and start reading the fine manual till my test environment becomes > available. > > > На пн, 17.02.2020 г., 18:21 CFouts <chrisfo...@ziftsolutions.com> написа: > >> The clearmake command is a shell command too correct? Try this syntax >> >> >> >> sh “”” >> >> your commands here >> “”” >> >> >> >> You will have to escape at least the the “$” symbols. >> >> >> >> Chris >> >> >> >> *From: *Dimitar Vassilev <dimitar.vassi...@gmail.com> >> *Reply-To: *<users@groovy.apache.org> >> *Date: *Monday, February 17, 2020 at 11:13 AM >> *To: *<users@groovy.apache.org> >> *Subject: *handling shell pipelines in Jenkins 2.164.3 >> >> >> >> Greeting fellows, >> >> >> >> can anyone point me how to handle shell pipelines in Jenkins 2.164.3 >> >> I'm having a problem with the following sample code >> >> >> >> stage('inject full build'){ >> steps{ >> script { >> sh "#!/usr/bin/env bash \n" + >> "clearmake setview -exec 'clearmake -k full' ${VIEW} | awk -F >> '<|>' 'NR ==2 { print $2 } ' > foo.txt" >> } >> } >> } >> >> The objective is to record the build id injected into the build queue and >> monitor the build status later with LSF bjobs command options. when I put >> the above syntax I get an error message like >> >> >> >> unexpected syntax error near unexpected token `|` >> >> >> >> Any pointers will be appreciated. >> >> Best regards, >> >> >> >> Dimitar >> >