其他分享
首页 > 其他分享> > Jenkins: Variable & Function

Jenkins: Variable & Function

作者:互联网

 

全局变量:  ${YOUR_JENKINS_HOST}/env-vars.html 页可以查看所有可用的内置环境变量

 

readJSON & writeJSON: 

println env.JOB_NAME
println env.BUILD_NUMBER
println env.WORKSPACE
println env.JENKINS_HOME

pipeline {

  agent any

  stages {
    stage("Read JSON From File") {
      steps {
        script {
          map = readJSON file: "/${JENKINS_HOME}/octopus/octopus.json"
          map.each {
            println "${it.key}: ${it.value}"
          }
        }
      }
    }
    stage('Write JSON To File') {
      steps {
        script {
          writeJSON file: "/${JENKINS_HOME}/octopus/write.json", json: map, pretty: 4
        }
      }
    }
  }
}

 

标签:Function,map,println,json,env,JENKINS,Variable,Jenkins,HOME
来源: https://www.cnblogs.com/dissipate/p/16367683.html