经过大量的挖掘(我从未意识到Jenkins的文档记录多么糟糕!),我找到了一个非常简单的解决方案。
- 安装Groovy插件
- 将A添加
Post Step
到您的Maven构建类型Execute **system** Groovy script
- 粘贴以下Groovy片段:
脚本:
import hudson.model.*;import hudson.util.*;def thr = Thread.currentThread();def currentBuild = thr?.executable;def mavenVer = currentBuild.getParent().getModules().toArray()[0].getVersion();def newParamAction = new hudson.model.ParametersAction(new hudson.model.StringParameterValue("MAVEN_VERSION", mavenVer));currentBuild.addAction(newParamAction);MAVEN_VERSION现在可以使用通常的方式(
${MAVEN_VERSION})将称为的构建环境变量替换为其他构建后步骤。我正在将它用于Git标记等。


