Jenkins Git插件尝试在发布版本期间构建旧版本

时间:2015-06-06 02:16:07

标签: git github jenkins jenkins-plugins maven-release-plugin

我尝试使用maven-release-plugin发布Maven项目。 Jenkins Git插件似乎没有正确检查回购。

以下是我的Jenkins作业配置

Repository URL : git@githubenterprise:/user/repo.git

Branches to build: */master

Repository browser: Auto

Additional Behaviours:

  Checkout to specific local branch : master

失败版本的Git Build数据显示

Revision: 267**
refs/remotes/origin/origin/master
Built Branches

refs/remotes/origin/master: Build #4 of Revision 755** 
(refs/remotes/origin/master)
refs/remotes/origin/origin/master: Build #10 of Revision 267*** 
(refs/remotes/origin/origin/master)

作业控制台显示

Multiple candidate revisions
Scheduling another build to catch up with MyJenkinsBuildJob
Checking out Revision 267** (refs/remotes/origin/origin/master)

755 **是存储库中的最新提交,即Git插件正在检查267 **修订版。因此,当maven-release-plugin尝试从旧提交中推回发布准备版本时,构建失败。

The git-push command failed.
Command output:
To ssh://git@githubenterprise:/user/repo.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'ssh://git@githubenterprise:/user/repo.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again.

如何让Jenkins Git插件只签出最新版本(在我的情况下为755 *),而不是尝试构建多个签出(不知道为什么会这样做)

1 个答案:

答案 0 :(得分:4)

这是因为有人推了一个名字&#34; origin / master&#34;这与我提供的Branches to build: */master配置相匹配。所以Git插件试图检查这两个匹配的分支(&#34; master &#34;和&#34; < em> origin / master &#34;)并构建它们

删除通配符并将分支说明符设置为remotes/origin/master解决了问题。