簡體   English   中英

Jenkins git maven 發布 - git push 失敗/更新被拒絕

[英]Jenkins git maven release - git push failed/updates were rejected

我正在嘗試使用 git 實現 Jenkins maven 版本。 我遵循了指南,但我的版本因以下錯誤而失敗。 它在推動時抱怨。 我正在使用工作區清理插件,所以每次都應該獲取項目的新副本。 我不確定為什么會收到此錯誤。

我嘗試添加一個 pre 步驟來執行“ 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://gitlab@abc.example.com/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]

我通過創建一個新的 jenkins 工作解決了這個問題。 之后一切正常。

你不應該在你的 release:prepare 即將更新的 repo 分支上完成遠程提交。 正如這里提到的,這是與同一個 repo 的其他貢獻者的溝通問題。

確保您的本地存儲庫是最新的 ( git pull ),然后啟動您的mvn命令。

這個GitLab 問題還建議:

您可以跳過推回 master 並只提交帶有新標簽的提交。

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

額外的好處:您不會因兩次發布提交而破壞 master 的提交歷史記錄。
當然,現在您需要以某種方式提高您的版本。
您可以通過包含此插件來使用 ci_pipeline_id 方法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM