using groovy-postbuild-plugin in my Jenkins pipeline

淺唱寂寞╮ 提交于 2020-12-07 06:50:32

问题


I'm trying to use the groovy-postbuild-plugin in my Jenkins pipeline, I can get it to work for displaying plain text, But I can't use it with parameters.

So this is working:

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

But this one doesn't:

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

This is the error I get:

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

回答1:


So it turns out that I could use the "creatrShortText" class and it will take what is inside the double quotes as a parameter. Something like that:

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



来源:https://stackoverflow.com/questions/48661032/using-groovy-postbuild-plugin-in-my-jenkins-pipeline

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!