oh, wow, thank you Rheinhold! vielen Dank! I see there is also a feature request to "Allow sh to return exit status, stdout and stderr all at once"
https://issues.jenkins-ci.org/browse/JENKINS-44930?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel On Wednesday, October 23, 2019 at 2:40:10 PM UTC+2, r.fuereder wrote: > > Hi, > > > > the „funny“ answer is: > > „java -version” prints the version information to stderr… > > > > HTH Reinhold > > > > > > *From:* [email protected] <javascript:> < > [email protected] <javascript:>> *On Behalf Of *Pa Y > *Sent:* Mittwoch, 23. Oktober 2019 13:40 > *To:* Jenkins Users <[email protected] <javascript:>> > *Subject:* pipelines: how to store script output into a variable? > > > > Hi, > > I looked extensively and the standard solution found in SO or other places > doesn't work for me.. do you know what is the problem and how to fix it? > > > > thanks for any help in advance! > > > > a sample pipeline: > > --- > > pipeline { > agent any > environment { > JAVA_INFO= "" > } > stages { > stage('test read info') { > steps { > script { > JAVA_INFO = sh(returnStdout: true, script: "java > -version") > sh("echo this is java: ${JAVA_INFO}") > } > } > } > } > } > ----------- > > > > EXPECTED OUTPUT: > > > > this is java: openjdk version "11.0.4" 2019-07-16 > > ... (more lines) > > CURRENT OUTPUT: (echo is empty) > > [Pipeline] sh > > + java -version > > openjdk version "11.0.4" 2019-07-16 > > OpenJDK Runtime Environment (build 11.0.4+11-post-Debian-1deb10u1) > > OpenJDK 64-Bit Server VM (build 11.0.4+11-post-Debian-1deb10u1, mixed mode, > sharing) > > [Pipeline] sh > > + echo this is java: > > this is java: > > [Pipeline] } > > [Pipeline] // script > > Regards, > > Pablo > > > > -- > 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/383d7586-8a5c-4d57-82c3-56ba9ce71ece%40googlegroups.com > > <https://groups.google.com/d/msgid/jenkinsci-users/383d7586-8a5c-4d57-82c3-56ba9ce71ece%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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/0c16900b-bc6c-48ea-a230-8d9774a4d221%40googlegroups.com.
