Git Jenkins无法获取changeId和revisionId

Git Jenkins无法获取changeId和revisionId,git,jenkins,jenkins-plugins,gerrit,gerrit-trigger,Git,Jenkins,Jenkins Plugins,Gerrit,Gerrit Trigger,我已经将Jenkins和Gerrit与Gerrit触发器插件进行了配置和集成,作为Jenkins中后期构建任务的一部分,我正在执行以下脚本: /opt/sputnik/bin/sputnik --conf /opt/sputnik/myconf.properties --changeId $GERRIT_CHANGE_ID --revisionId $GERRIT_PATCHSET_REVISION echo "exit 0 workaround" 以下是人造卫星: 但我得到了以下结果: [P

我已经将Jenkins和Gerrit与Gerrit触发器插件进行了配置和集成,作为Jenkins中后期构建任务的一部分,我正在执行以下脚本:

/opt/sputnik/bin/sputnik --conf /opt/sputnik/myconf.properties --changeId $GERRIT_CHANGE_ID --revisionId $GERRIT_PATCHSET_REVISION
echo "exit 0 workaround"
以下是人造卫星:

但我得到了以下结果:

[PostBuildScript] - Execution post build scripts.
[PostBuildScript] - Resolving environment variables for the script content.
[PostBuildScript] - Evaluating the script: 
/var/lib/jenkins/sputnik/bin/sputnik --conf /var/lib/jenkins/sputnik/gerrit.properties --changeId $GERRIT_CHANGE_ID --revisionId $GERRIT_PATCHSET_REVISION
echo "exit 0 workaround"

[project1] $ /bin/sh -xe /tmp/hudson6990025050616459512.sh
+ /var/lib/jenkins/sputnik/bin/sputnik --conf /var/lib/jenkins/sputnik/gerrit.properties --changeId --revisionId
Sputnik version 1.7.0
Sputnik - review your Gerrit patchset with Checkstyle, PMD and FindBugs
usage: sputnik [--apiKey <apiKey>] [--buildId <buildId>] [--changeId <changeId>] --conf <conf> [--pullRequestId
   <pullRequestId>] [--revisionId <revisionId>]
--apiKey <apiKey>                 Optional API key for using Sputnik for Github
--buildId <buildId>               Optional build id for using Sputnik for Github
--changeId <changeId>             Gerrit change id
--conf <conf>                     Configuration properties file
--pullRequestId <pullRequestId>   Stash pull request id
--revisionId <revisionId>         Gerrit revision id
Missing argument for option: changeId
Build step 'Execute a set of scripts' changed build result to FAILURE
Build step 'Execute a set of scripts' marked build as failure
Finished: FAILURE
[PostBuildScript]-执行生成后脚本。
[PostBuildScript]-解析脚本内容的环境变量。
[PostBuildScript]-评估脚本:
/var/lib/jenkins/sputnik/bin/sputnik--conf/var/lib/jenkins/sputnik/gerrit.properties--changeId$gerrit\u CHANGE\u ID--revisionId$gerrit\u PATCHSET\u REVISION
回显“退出0解决方案”
[project1]$/bin/sh-xe/tmp/hudson6990025050616459512.sh
+/var/lib/jenkins/sputnik/bin/sputnik--conf/var/lib/jenkins/sputnik/gerrit.properties--changeId--revisioniid
人造卫星1.7.0版
Sputnik-使用Checkstyle、PMD和FindBugs查看Gerrit补丁集
用法:sputnik[--apiKey][--buildId][--changeId]--conf[--pullRequestId
][--修订ID]
--apiKey使用Sputnik for Github的可选API密钥
--buildId使用Sputnik for Github的可选构建id
--更改id Gerrit更改id
--配置属性文件
--pullRequestId隐藏pull请求id
--修订id Gerrit修订id
缺少选项的参数:changeId
生成步骤“执行一组脚本”将生成结果更改为失败
生成步骤“执行一组脚本”标记为生成失败
完成:失败
该问题是由Jenkins引起的-它适用于
1.651.2
2.3
及更高版本。 这是一个例子

基本上,它禁止插件注入未明确配置用于构建的参数,因此Jenkins不知道
$GERRIT\u CHANGE\u ID
$GERRIT\u PATCHSET\u REVISION

根据:

作为一种解决方法,您可以将以下JAVA_ARG添加到jenkins配置中

-Dhudson.model.ParametersAction.keepUndefinedParameters=true

然而,我发现这个解决方案太具侵入性,所以我想出了另一个解决方案。只需将以下字符串参数添加到作业配置:

  • GERRIT_CHANGE_ID

  • GERRIT_补丁集_修订版

就这样。现在,您的配置应该如下所示:


如果您正在以wrogn方式使用Sputnik,请参阅输出。changeId和revisionId需要一个值。