Dixon Almeida Dixon Almeida - 9 months ago 68
Groovy Question

How to access global environment through groovy script in Jenkins Pipeline Plugin

In shell we use following command

sh "x=${env.j_properties_file}"
sh "y=${env.HOME}"

How do we it in groovy script Or How do we access shell variable x in groovy script?

Answer Source

you can't access them directly, but according to the reference you can catch stdout from your sh step:

    def xx = sh(returnStdout:true, script:"""
        echo \${x}

    echo "the shell output = ${xx}"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download