首页 > 解决方案 > Jenkins - 在构建时创建 Git 分支

问题描述

我有一个 Jenkins 构建,完成后我希望在远程存储库中为发布创建一个分支。

我有这样的 git 发布设置: 在此处输入图像描述

但是当我运行它时,标记似乎没问题,但是分支给出了:

ERROR: Failed to push branch RELEASE-5 to jsched
 hudson.plugins.git.GitException: Command "git.exe push 
 https://myid@git.server:9443/scm/win/jsched.git HEAD:RELEASE-5" returned status code 1:

 stderr: error: unable to push to unqualified destination: RELEASE-5
  The destination refspec neither matches an existing ref on the remote nor
  begins with refs/, and we are unable to guess a prefix based on the source ref.
 error: failed to push some refs to 'https://myid@git.server:9443/scm/win/jsched.gitt'

我究竟做错了什么?

标签: gitjenkins

解决方案


您正在将本地 RELEASE-ID 分支推送到远程,但问题是由于它是一个新创建的分支,它没有定义上游,因此 git 不知道将提交推送到哪里。

如果您“手动”执行此操作,您会告诉 git 使用 remote/RELEASE-ID 作为上游。Jenkins 界面不允许您定义此类行为。也许你可以用脚本实现类似的东西。


推荐阅读