如何避免“由于遥控器包含工作而拒绝更新".在发布期间使用maven release-plugin和git? [英] How to avoid "Updates were rejected because the remote contains work" during release with maven release-plugin and git?

查看:271
本文介绍了如何避免“由于遥控器包含工作而拒绝更新".在发布期间使用maven release-plugin和git?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们最近从SVN迁移到了git.除了在git上进行发布的其他(意外)问题之外,我想知道如何处理以下问题:

We recently migrated from SVN to git. Beside other (unexpected) issues doing releases on git, I am wondering how to deal with the following issue:

当我在Jenkins上启动发布运行并且某些开发人员(偶然地)在发布的第一阶段进行推送时,发布构建失败,并出现以下错误:

When I start a release-run on Jenkins and some developer (accidentally) pushes during the first phase of the release, the release build fails with the following error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.3:prepare (default-cli) on project xyz: Unable to commit files
[ERROR] Provider message:
[ERROR] The git-push command failed.
[ERROR] Command output:
[ERROR] To ssh://[some-ip]/home/git/xyz
[ERROR] ! [rejected]        release/xyz-6.10 -> release/xyz-6.10 (fetch first)
[ERROR] error: failed to push some refs to 'ssh://[some-ip]/home/git/xyz'
[ERROR] hint: Updates were rejected because the remote contains work that you do
[ERROR] hint: not have locally. This is usually caused by another repository pushing
[ERROR] hint: to the same ref. You may want to first integrate the remote changes
[ERROR] hint: (e.g., 'git pull ...') before pushing again.
[ERROR] hint: See the 'Note about fast-forwards' in 'git push --help' for details.
[ERROR] -> [Help 1]

Jenkins用于启动发行版构建的maven命令是(我们在Windows上构建,因此很遗憾,由于git add上的命令行太长,包括所有已修改的pom.xml,因此我们不得不激活-DautoVersionSubmodules) :

The maven command used by Jenkins to initiate the release build is (we build on Windows, so we unfortunately have to activate -DautoVersionSubmodules due to otherwise too long command line on the git add including all the modified pom.xml):

mvn -B -DdevelopmentVersion=xyz-6.10.0-rc3-SNAPSHOT -DreleaseVersion=xyz-6.10.0-rc2 -Dtag=xyz-6.10.0-rc2 -Dresume=false -e -Dgoals=deploy -DautoVersionSubmodules=true -DcommitByProject=true -P[some-profiles] -T1C release:prepare release:perform -Darguments=-T1C

是否有一种简单的方法来阻止其他用户推送(但允许Jenkins推送!)?还是其他稳定的解决方案或最佳做法?

Is there a simple way to block other users from pushing (but allow Jenkins to push!)? Or any other stable work around - or best practice?

使用的版本:

  • Maven 3.3.9
  • Maven Release-Plugin 2.5.3
  • Git 2.8.1
  • 詹金斯1.629
  • Jenkins Maven Release插件0.14.0
  • Windows 10

预先感谢您的帮助.

推荐答案

我希望您同意发行失败是正确的.在这种情况下,要解决的问题并不大:更新项目并进行另一个发行. 解决此问题的最简单方法是:交流:)只需通知同事您计划进行此发行. 我听说的另一种解决方案是:首先创建一个分支,然后从该分支中​​释放.没有人会更改分支的内容,因此这应该是一个安全的解决方案,但是需要额外的工作.由您决定是否值得.在大多数情况下不是.

I hope you agree that is was correct that the release failed. And in this case it is not a big issue to fix: update the project and do another release. The easiest way to fix this is: communication :) Simply informing coworkers that you plan to do this release. Another solution I have heard of is: create a branch first and release from this branch. Nobody will change the content of the branch, so this should be a safe solution, but it requires extra work. It's up to you to decide if it's worth it. Most of the time it is not.

这篇关于如何避免“由于遥控器包含工作而拒绝更新".在发布期间使用maven release-plugin和git?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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