我目前正在尝试在Git项目中使用jenkins中的maven-release-plugin
。
如下所示,我的远程存储库(在服务器上)似乎缺少对HEAD的引用。仅在主分支名称已更改为其他内容的项目中缺少此引用。
10:12 $ git ls-remote https://git.mycompany.com/mycompany/common.git
cb6fd9d62d963e9d20499e7dcfcfc8742e799333 refs/heads/development
5fd387bcbaf56312a108b1e07236a25a325f1a79 refs/heads/production
d5d97e7ce2c634ce5ab8cb7d68a2cf9c67ece2ea refs/tags/1.0.0
1317bcd74008313f0a9933d840fbcd4356ed51c7 refs/tags/1.0.0^{}
有没有办法从GitLab或使用Git远程创建这种引用?
以下是来自maven-release-plugin的执行日志:
[INFO] --- maven-release-plugin:2.5.1:perform (default-cli) @ common ---
[INFO] Checking out the project to perform the release ...
[INFO] Executing: /bin/sh -c cd /var/lib/jenkins/jobs/common/workspace/common/target && git clone --branch 1.0.1 https://git.mycompany.com/mycompany/common.git /var/lib/jenkins/jobs/common/workspace/common/target/checkout
[INFO] Working directory: /var/lib/jenkins/jobs/common/workspace/common/target
[INFO] Executing: /bin/sh -c cd /tmp && git ls-remote https://git.mycompany.com/mycompany/common.git
[INFO] Working directory: /tmp
[INFO] Executing: /bin/sh -c cd /var/lib/jenkins/jobs/common/workspace/common/target/checkout && git fetch https://git.mycompany.com/mycompany/common.git
[INFO] Working directory: /var/lib/jenkins/jobs/common/workspace/common/target/checkout
[ERROR] The git-pull command failed.
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] common ............................................. FAILURE [ 32.825 s]
[INFO] common :: common-validation ........................ SKIPPED
[INFO] common :: common-sessions .......................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 33.960 s
[INFO] Finished at: 2015-02-03T10:39:04+01:00
[INFO] Final Memory: 20M/395M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.1:perform (default-cli) on project common: Unable to checkout from SCM
[ERROR] Provider message:
[ERROR] The git-pull command failed.
[ERROR] Command output:
[ERROR] Cloning into '/var/lib/jenkins/jobs/common/workspace/common/target/checkout'...
[ERROR] Note: checking out '78ec6e9c81d25890de75ce671d809bf5d3949ed8'.
[ERROR]
[ERROR] You are in 'detached HEAD' state. You can look around, make experimental
[ERROR] changes and commit them, and you can discard any commits you make in this
[ERROR] state without impacting any branches by performing another checkout.
[ERROR]
[ERROR] If you want to create a new branch to retain commits you create, you may
[ERROR] do so (now or later) by using -b with the checkout command again. Example:
[ERROR]
[ERROR] git checkout -b new_branch_name
[ERROR]
[ERROR] fatal: Couldn't find remote ref HEAD
[ERROR] Unexpected end of command stream
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
答案 0 :(得分:3)
显然这是与GitLab相关的问题。
默认分支已设置但在设置(在项目设置中)默认情况下另一个分支后,出现了HEAD引用:
cb6fd9d62d963e9d20499e7dcfcfc8742e799333 HEAD
cb6fd9d62d963e9d20499e7dcfcfc8742e799333 refs/heads/development
07bef68adb8d10956bdba81d07887f793feab76b refs/heads/production
d5d97e7ce2c634ce5ab8cb7d68a2cf9c67ece2ea refs/tags/1.0.0
1317bcd74008313f0a9933d840fbcd4356ed51c7 refs/tags/1.0.0^{}
我将它切换回默认分支,HEAD仍在那里。
发布过程成功
答案 1 :(得分:1)
当我的存储库尚未创建master
分支时,我遇到了同样的错误。
$ git branch master
解决了我的问题。