Re: Output of shell command into a variable

2016-10-21 Thread Sam K
Your answer works like a charm, but will still give me a problem with the newline in the end. I added the trim() from the stackoverflow answer and now the output is what I want. Thanks again!! Sam On Friday, October 21, 2016 at 5:20:16 PM UTC-7, Mark Waite wrote: > > If you're inside a pipe

Re: Output of shell command into a variable

2016-10-21 Thread Mark Waite
If you're inside a pipeline script and calling sh (or bat), then you can use a slightly different syntax and it will assign the output of the shell command as the return value. See https://github.com/MarkEWaite/jenkins-bugs/blob/2e662560a42571b18ec32d78d1ac730952075d78/Jenkinsfile#L52 for an examp

Output of shell command into a variable

2016-10-21 Thread Sam K
Currently, I'm doing this. sh ' > /tmp/aa' def VAR1 = readFile('/tmp/aa') This mostly works. But oftentimes the variable has a newline and so it messes up its usage. Is there a better way to store the output in a variable without having to deal with the newline? thanks -- You received