简体   繁体   中英

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

In shell we use following command

  node{
     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?

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

node{
    def xx = sh(returnStdout:true, script:"""
        x=${env.j_properties_file}
        echo \${x}
    """)

    echo "the shell output = ${xx}"
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM