简体   繁体   中英

using groovy-postbuild-plugin in my Jenkins pipeline

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

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");
}

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM