在我的Jenkins管道中使用groovy-postbuild-plugin [英] using groovy-postbuild-plugin in my Jenkins pipeline

查看:465
本文介绍了在我的Jenkins管道中使用groovy-postbuild-plugin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

这是可行的:

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

推荐答案

因此,事实证明我可以使用"creatrShortText"类,并且它将双引号内的内容作为参数. 像这样的东西:

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

这篇关于在我的Jenkins管道中使用groovy-postbuild-plugin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆