I can execute the following on a command line, where I just want to 
checkout a feature/* branch, and if the sub module does not have it, I want 
to checkout master.
$ git submodule foreach 'git checkout feature/test-new-scripts || git 
checkout master'

However, if I execute the same command in a Jenkins pipeline, I get a 
syntax error.
sh """
 git submodule foreach \\'git checkout feature/test-new-scripts || git 
checkout master\\' 
""" 

I get the following error
+ git submodule foreach "git checkout feature/test-new-scripts
Entering 'module1' 
"git: 1: "git: Syntax error: Unterminated quoted string
fatal: run_command returned non-zero status for module1 
. 
+ git checkout master" error: pathspec 'master"' did not match any file(s) 
known to git

I've tried the following syntax, where I just changed the single quotes (
'...') in the command itself to double quotes ("..."), to no avail
sh """
 git submodule foreach \\"git checkout feature/test-new-scripts || git 
checkout master\\"
"""

What is the correct syntax do accomplish what I want to do? TIA

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/68b54367-f10c-4159-a50c-d8a80ef23128n%40googlegroups.com.

Reply via email to