Retrieve all properties of env in Jenkinsfile

前端 未结 3 1296
青春惊慌失措
青春惊慌失措 2020-12-18 18:57

I would like to print all available properties (and their values) in env object inside Jenkinsfile.

When I do

print env
<
相关标签:
3条回答
  • 2020-12-18 19:17

    To retrieve all env properties using a Jenkinsfile written in either declarative or scripted DSL you can use:

    sh 'env'                       
    

    or

    sh 'printenv'
    
    0 讨论(0)
  • 2020-12-18 19:19

    As said over here: https://stackoverflow.com/a/42138466/618253

    The declarative pipeline way of doing things:

    node {
       echo sh(returnStdout: true, script: 'env')
    }
    
    0 讨论(0)
  • 2020-12-18 19:22

    Make sure you're not running the pipeline script in sandboxed mode and you should be able to use:

    env.getEnvironment()
    

    Note, if you're running in sandbox mode in a pipeline, you should approve the method at the script approval page: http://jenkins-host/scriptApproval/

    0 讨论(0)
提交回复
热议问题