无法在2.7.3中访问Jenkins文件中使用EnvInject注入的变量

时间:2017-01-26 17:59:47

标签: jenkins jenkins-pipeline

我" [准备]跑步的环境"像这样,在我的管道项目中:

Prepared Environment

然而,每当我尝试在我的Jenkins文件中看到this example时(看起来像这样):

node {
    currentBuild.result = "SUCCESS"
    try {   
        stage("Checkout") {
            checkout scm
        }

        stage("Setup") {
            def API_BASE_URL = env.API_BASE_URL
            print "API_BASE_URL : ${API_BASE_URL}"
        }
    } catch (err) {
        currentBuild.result = "FAILURE"
        print "Build failed"
        print err
        throw err
    }
}

我最终得到了这个,在我的日志中:

Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Setup)
[Pipeline] echo
API_BASE_URL : null
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS

有什么想法吗?

0 个答案:

没有答案