Hi,

the „funny“ answer is:
„java -version” prints the version information to stderr…

HTH Reinhold


From: [email protected] <[email protected]> On 
Behalf Of Pa Y
Sent: Mittwoch, 23. Oktober 2019 13:40
To: Jenkins Users <[email protected]>
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]<mailto:[email protected]>.
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/AM0PR01MB6147036C9582529076C95F18F76B0%40AM0PR01MB6147.eurprd01.prod.exchangelabs.com.

Reply via email to