出于某种原因,在运行 maven 版本时,它只为推送的标记部分提供了一个无效的 URL。对于 pom.xml 提交/推送,它工作正常并转到适当的 URL。见下文:
[INFO] Working directory: /opt/jenkins-home/jobs/Section 4362/workspace/section4362-parent
[INFO] Executing: /bin/sh -c cd "/opt/jenkins-home/jobs/Section 4362/workspace/section4362-parent" && git commit --verbose -F /tmp/maven-scm-217365030.commit '/opt/jenkins-home/jobs/Section 4362/workspace/section4362-services/pom.xml' '/opt/jenkins-home/jobs/Section 4362/workspace/section4362-webapp/pom.xml' '/opt/jenkins-home/jobs/Section 4362/workspace/section4362-static/pom.xml' pom.xml
[INFO] Working directory: /opt/jenkins-home/jobs/Section 4362/workspace/section4362-parent
[INFO] Executing: /bin/sh -c cd "/opt/jenkins-home/jobs/Section 4362/workspace/section4362-parent" && git symbolic-ref HEAD
[INFO] Working directory: /opt/jenkins-home/jobs/Section 4362/workspace/section4362-parent
[INFO] Executing: /bin/sh -c cd "/opt/jenkins-home/jobs/Section 4362/workspace/section4362-parent" && git push ssh://git@github.com/{org}/Section4362.git maven-release-test:maven-release-test
[INFO] Working directory: /opt/jenkins-home/jobs/Section 4362/workspace/section4362-parent
[INFO] Tagging release with the label section4362-parent-0.3...
[INFO] Executing: /bin/sh -c cd "/opt/jenkins-home/jobs/Section 4362/workspace" && git tag -F /tmp/maven-scm-882610155.commit section4362-parent-0.3
[INFO] Working directory: /opt/jenkins-home/jobs/Section 4362/workspace
[INFO] Executing: /bin/sh -c cd "/opt/jenkins-home/jobs/Section 4362/workspace" && git push ssh://git@github.com/{org} section4362-parent-0.3
[INFO] Working directory: /opt/jenkins-home/jobs/Section 4362/workspace
可以看到提交后的推送,推送到ssh://git@github.com/{org}/Section4362.git
({org}被我擦掉了),而对于标签后的推送,它转到 ssh://git@github.com/{org}
– URL 应该在末尾包含 /Section4362.git
。我所有的 pom 文件都指定了正确的:scm:git:ssh://git@github.com/{org}/Section4362.git
标签推送的 URL 将如何变化,它从哪里获取? Build 显然在那一步失败,说无法连接到 repo。
最佳答案
我遇到了同样的问题。 我使用 jdk 1.7,maven 3.3.9 和 maven-release plugin 2.5.3
我查看了与此问题相关的 jira,但没有发现它已修复 :-(
https://issues.apache.org/jira/browse/MRELEASE-939
https://issues.apache.org/jira/browse/MRELEASE-927
我发现了一个技巧,使 maven 不会截断用于推送标签的 url。
我在 pom.xml 中精确地推送和获取 SCM url,使用相同的 url。重要的是首先定义推送 url 然后获取而不是相反。 这是一个例子。
<scm>
<connection>scm:git:https://gitlab.com/gitlab-org/java-project-template-single-scm.git</connection>
<developerConnection>scm:git:[push=]https://gitlab.com/gitlab-org/java-project-template-single-scm.git[fetch=]https://gitlab.com/gitlab-org/java-project-template-single-scm.git</developerConnection>
<url>https://gitlab.com/gitlab-org/java-project-template-single-scm.git</url>
<tag>HEAD</tag>
</scm>
关于git - 为 Maven 发布标签推送截断 SCM (git) URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23563685/