我们最近从SVN迁移到git。除了其他(意外的)在git上发布的问题之外,我想知道如何处理以下问题:
当我在Jenkins上启动发布运行时,如果一些开发人员(意外地)在发布的第一阶段推送代码,那么发布构建将失败,并显示以下错误:
[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上进行构建,因此不幸地需要激活-DautoVersionSubmodules
,否则git add
将包括所有修改的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推送)?或者任何其他稳定的解决方法-或最佳实践?
使用的版本:
- Maven 3.3.9 - Maven Release-Plugin 2.5.3 - Git 2.8.1 - Jenkins 1.629 - Jenkins Maven Release插件0.14.0 - Windows 10
非常感谢您的帮助。