【问题标题】:Truncating SCM (git) URL for maven release tag push截断 Maven 发布标签推送的 SCM (git) URL
【发布时间】:2017-03-03 18:37:53
【问题描述】:

由于某种原因,在运行 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 将如何变化?它从哪里获取?构建显然在这一步失败,说无法连接到 repo。

【问题讨论】:

    标签: git maven maven-release-plugin


    【解决方案1】:

    maven-release-plugin 中存在一个未解决的问题,必须修复它才能使事情正常运行。有关详细信息,请参阅http://jira.codehaus.org/browse/MRELEASE-767。不幸的是,在解决 git URL 翻译中的错误之前,除了不将更改推送到 git 之外,没有什么可以做的。

    【讨论】:

    【解决方案2】:

    我遇到了同样的问题。 我使用 jdk 1.7、maven 3.3.9 和 maven-release 插件 2.5.3

    我查看了与此问题相关的 jira,但没有发现它已修复 :-(

    https://issues.apache.org/jira/browse/MRELEASE-939

    https://issues.apache.org/jira/browse/MRELEASE-927

    我发现了一个技巧,让 maven 不会对用于推送标签的 url 进行 troncate。

    我使用相同的 url 在 pom.xml 中精确地推送和获取 SCM url。首先定义 push url 然后 fetch 而不是相反是很重要的。 这是一个例子。

    <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>
    

    【讨论】:

    • 不错的解决方法。唯一的其他解决方法是扔掉 maven-release-plugin 并只使用 versions-maven-plugin 和 maven-scm-plugin 像:axelfontaine.com/blog/final-nail.html
    • 非常感谢您记录此解决方法。我想添加以下内容:如果您有像scm:git:git@host:group:project.git 这样的连接,则此技巧不起作用,整个地址都会爆炸。在这种情况下,请切换到 ssh 表示法,例如 scm:git:ssh://git@host/group/project.git。使用此表示法,可以应用推送/获取解决方法:scm:git:[push=]ssh://git@host/group/project.git[fetch=]ssh://git@host/group/project.git。 (对不起,如果有错别字,我不能在这里粘贴我客户的实际网址)
    猜你喜欢
    • 2016-09-19
    • 1970-01-01
    • 2021-07-13
    • 2014-12-05
    • 2012-03-20
    • 1970-01-01
    • 2016-06-18
    • 2011-07-26
    相关资源
    最近更新 更多