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 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 example, or the stackoverflow answer at > http://stackoverflow.com/questions/36507410/is-it-possible-to-capture-the-stdout-from-the-sh-dsl-command-in-the-pipeline# > . > > Mark Waite > > On Fri, Oct 21, 2016 at 12:08 PM Sam K <[email protected] <javascript:>> > wrote: > >> Currently, I'm doing this. >> >> sh '<some-command> > /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 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] <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/jenkinsci-users/f12a1391-bf74-41f9-9c6e-9eab354b7ea6%40googlegroups.com >> >> <https://groups.google.com/d/msgid/jenkinsci-users/f12a1391-bf74-41f9-9c6e-9eab354b7ea6%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- 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/7fe9c311-2cee-46ba-81ee-9e255c1a3c53%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
