我正在尝试使用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://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]
答案 0 :(得分:1)
我通过创建新的詹金斯工作解决了该问题。之后一切都很好。
答案 1 :(得分:0)
您不应在release:prepare即将更新的repo分支上进行远程提交。与mentioned here一样,这是与同一回购协议的其他贡献者之间的沟通问题。
确保您的本地存储库是最新版本(git pull
),然后启动mvn
命令。
此GitLab issue还建议:
您可以跳过推回master的操作,而只需提交带有新标记的提交。
运行
mvn release:prepare release:perform -DpushChanges=false git push —tags
其他好处:您不会因为两次发布提交而破坏了master的提交历史。
当然,现在您需要以某种方式更改您的版本。
您可以通过inclusion of this plugin使用ci_pipeline_id方法。