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]> 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]. > 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/CAO49JtEu_rAqBGVJsQRx8nvPhUscdmhy8jhDRdQaNPG5oiERRg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
