I'm trying to get a shell command with pipes working with Jenkins Pipelines. It's related to: Jenkins pipeline sh does not seem to respect pipe in shell command. I also found: Jenkins pipeline, bash, and pipes
However, my success with it has been unsuccessful. I can literally copy/paste the resolution of the first post in my pipeline and it does work (at least it tries execute the shell, fails due to lack of pom.xml).
When I attempt to modify the shell command to my needs, it falls flat:
def bgd_discovery = $/eval "cf apps | grep ${appHost}.${host} | cut -d ' ' -f 1 | sed 's/${args.appName}-bgd//'"/$
echo "${bgd_discovery}"
Jenkins throws a DSL method error:
java.lang.NoSuchMethodError: No such DSL method 'eval "cf apps | grep [...app host...] | cut -d ' ' -f 1 | sed 's' found among steps [...]
It seems to stop at first /
of sed, but that's not the problem because this does work (from the first post):
def ver_script = $/eval "sed -n '/<version>/,/<version/p' pom.xml | head -1 | sed 's/[[:blank:]]*<\/*version>//g'"/$
Interestingly, here's another symptom to a problem: An added hyphen to the end of the sed
regex
def bgd_discovery = $/eval "cf apps | grep ${appHost}.${host} | cut -d ' ' -f 1 | sed 's/${args.appName}-bgd-//'"/$
Produced this error:
WorkflowScript: 26: expecting '}', found '' @ line 26, column 10.
echo "${bgd_discovery}"
I can't figure out what's wrong.