How to list all `env` properties within jenkins pipeline job?

前端 未结 15 1766
情深已故
情深已故 2020-11-30 22:20

Given a jenkins 2.1 build pipeline, jenkins injects a env variable into the node{}. For example, BRANCH_NAME can be accessed with

15条回答
  •  情话喂你
    2020-11-30 22:33

    The answers above, are now antiquated due to new pipeline syntax. Below prints out the environment variables.

    script {
            sh 'env > env.txt'
            String[] envs = readFile('env.txt').split("\r?\n")
    
            for(String vars: envs){
                println(vars)
            }
        }
    

提交回复
热议问题