找不到远程 ref HEAD(使用 Jenkins 和 Maven 发布工件时)
Couldn't find remote ref HEAD (when releasing artifact with Jenkins and Maven)
我目前正尝试在 Git 项目中使用在 jenkins 中工作的 maven-release-plugin
。
如下所示,我的远程存储库(在服务器上)中似乎缺少对 HEAD 的引用。此引用仅在 master 分支名称已更改为其他名称的项目中丢失。
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:
显然这是一个与 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 还在。
并且发布过程成功
当我的存储库还没有创建 master
分支时,我遇到了同样的错误。
$ git branch master
解决了我的问题。
我目前正尝试在 Git 项目中使用在 jenkins 中工作的 maven-release-plugin
。
如下所示,我的远程存储库(在服务器上)中似乎缺少对 HEAD 的引用。此引用仅在 master 分支名称已更改为其他名称的项目中丢失。
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:
显然这是一个与 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 还在。
并且发布过程成功
当我的存储库还没有创建 master
分支时,我遇到了同样的错误。
$ git branch master
解决了我的问题。