有没有一种方法可以从无类Groovy脚本的call()方法访问全局变量?

时间:2020-08-10 14:38:10

标签: groovy jenkins-pipeline jenkins-groovy

我正在使用您的Jenkins管道脚本之一。
我有一个默认为false的全局变量skipTests,还有一个我打算用来覆盖它的可选配置。

不幸的是,它未能说明skipTests不存在。

错误:

groovy.lang.MissingPropertyException: No such property: skipTests for class: script999999999999999999

代码:

boolean skipTests = false;
boolean qualityGateEnabled = true;

def TRUE = "true";

void call(){
    echo """|Integration Testing
            |Repo Name: $REPO_NAME
            |Branch Name: $BRANCH_NAME""".stripMargin();

    if (config.int_test != null) {
        ... override values ...
    }
    echo "${REPO_NAME} - Integration Testing Enabled: ${skipTests}"; // << FAILS HERE
    echo "${REPO_NAME} - Quality Gate Enabled: ${qualityGateEnabled}";

    if (skipTests) {
        echo "${REPO_NAME} - Skipping the Integration test step.";
    } else {
        ... do work ...
    }

0 个答案:

没有答案