【问题标题】:Git Publisher tagging earlier revision?Git Publisher 标记早期版本?
【发布时间】:2014-07-29 05:51:34
【问题描述】:

有没有办法配置 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.

【问题讨论】:

    标签: git jenkins merge tags publisher


    【解决方案1】:

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

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

    经过几天的摸索,我发现了基于this question的解决方法:

    在 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 变量已由上游作业设置)

    【讨论】:

      猜你喜欢
      • 2023-03-04
      • 2015-12-12
      • 2018-01-14
      • 1970-01-01
      • 2010-11-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多