Jenkins git maven发布 - git push failed / updates被拒绝

问题描述 投票:1回答:2

我试图用git实现Jenkins maven发布。我跟着this指南,但我的发布失败,出现以下错误。在推动时抱怨。我正在使用工作区清理插件,所以每次它应该采取项目的新副本。我不知道为什么我会收到此错误。

我试图添加一个预备步骤,它将执行“git fetch”和“git pull origin master”,但我仍然得到错误。它似乎是在jenkins工作区以外的地方创建本地仓库。有人能指出我正确的方向吗?

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

我通过创建一个新的jenkins工作来解决这个问题。之后一切都很好。


0
投票

您不应该在repo分支上完成远程提交:prepare即将更新。作为mentioned here,这是与同一回购的其他贡献者的沟通问题。

确保你的本地仓库是最新的(git pull),然后启动你的mvn命令。

这个GitLab issue还建议:

您可以跳过推回到master并使用新标记进行提交。

mvn release:prepare release:perform -DpushChanges=false
git push —tags

额外的好处:你不会破坏master的提交历史记录与两个release-commit。 当然,现在你需要以某种方式碰撞你的版本。 您可以通过inclusion of this plugin使用ci_pipeline_id方法。

© www.soinside.com 2019 - 2024. All rights reserved.