2

有没有办法配置 Jenkins 和 Git Publisher 插件来标记不在主分支头部的修订?

我们希望通过几个步骤来管理我们的集成过程,按顺序验证我们的软件,并通过标记已通过第一步的最新修订以自动方式促进这一点,然后在该修订通过时添加另一个标签第二步。在此期间,一些后来的修订可能会导致第一步失败或其他什么,因此我们不再将标签添加到头部。我们设想的其他一些场景也可能需要这种非头部标记。

我尝试在执行命令步骤中检查所需的标签,或者在 Git SCM 分支字段中指定标签,但我一直遇到非 ff 合并错误,因为在应用标签后我无法拉取或变基。

唯一被推送的更改是添加的标签。

这可能吗?

这是控制台输出中的内容:

 > /usr/bin/git tag -l test-tag
 > /usr/bin/git tag -a -f -m Testing tag built from environment variable test-tag
Pushing tag test-tag to repo origin
 > /usr/bin/git config --get remote.origin.url
 > /usr/bin/git push ssh://jenkins@ncs-gerrit.inhouse.com:29418/ncs-test test-tag
ERROR: Failed to push tag test-tag to origin
hudson.plugins.git.GitException: Command "/usr/bin/git push ssh://jenkins@ncs-gerrit.inhouse.com:29418/ncs-test test-tag" returned status code 1:
stdout: 
stderr: To ssh://jenkins@ncs-gerrit.inhouse.com:29418/ncs-test
 ! [rejected]        test-tag -> test-tag (non-fast-forward)
error: failed to push some refs to 'ssh://jenkins@ncs-gerrit.inhouse.com:29418/ncs-test'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.
4

1 回答 1

0

这尚不可用,但有一张票:

https://issues.jenkins-ci.org/browse/JENKINS-22499

经过几天的挠头,我发现了基于这个问题的解决方法:

在 jenkins 盒子上缓存 git 凭据:

$ git config --global credential.helper 'cache --timeout 600'

这使得凭证可用于 Jenkins 中的 Execute Shell 构建步骤:

$ /usr/local/bin/git tag -a "v${APPLICATION_VERSION}(${BUILD_DISPLAY_NAME})" ${GIT_COMMIT} -m "Tag at ${BUILD_ID}"
$ /usr/local/bin/git push Bitbucket "v${APPLICATION_VERSION}(${BUILD_DISPLAY_NAME})"

(注意:APPLICATION_VERSION 和 GIT_COMMIT 变量已由上游作业设置)

于 2014-10-13T12:50:00.297 回答