【问题标题】:using groovy-postbuild-plugin in my Jenkins pipeline在我的 Jenkins 管道中使用 groovy-postbuild-plugin
【发布时间】:2018-02-07 10:09:29
【问题描述】:

我正在尝试在我的 Jenkins 管道中使用 groovy-postbuild-plugin, 我可以让它用于显示纯文本, 但我不能将它与参数一起使用。

所以这是有效的:

stage('postbuild disply service built') {
    currentBuild.rawBuild.getActions().add(GroovyPostbuildAction.createShortText("test"));
}

但是这个没有:

stage('postbuild disply service built') {
    manager.addShortText("${manager.build.buildVariables.get('REPO_NAME')}");
}

这是我得到的错误:

org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: unclassified field org.jenkinsci.plugins.workflow.job.WorkflowRun buildVariables

【问题讨论】:

    标签: jenkins groovy


    【解决方案1】:

    事实证明,我可以使用“creatrShortText”类,它将双引号内的内容作为参数。 类似的东西:

    stage('postbuild display service and branch') {
        currentBuild.rawBuild.getActions().add(GroovyPostbuildAction.createShortText("${REPO_NAME}"));
        manager.addShortText("${SCM_BRANCH}", "black", "white", "1px", "green");
    }
    

    【讨论】:

      最近更新 更多