【问题标题】:Teamcity prepare release failed due to project name got appended to FETCH URL由于项目名称附加到 FETCH URL,Teamcity 准备发布失败
【发布时间】:2018-09-28 11:41:35
【问题描述】:

我正在使用 release-plugin 通过 Temcity 准备发布 我得到以下错误

[10:46:19][Step 2/3] [INFO] Executing: /bin/sh -c cd
/home/tcagent/buildAgent/work/860f91e0ad4abff2 && git push
https://username:****@testurl.com:8081/scm/myrepo/my-project-name.git/**buildConfName**
refs/heads/release/release-name:refs/heads/release/release-name

[10:46:19][Step 2/3] [INFO] Working directory:
/home/tcagent/buildAgent/work/860f91e0ad4abff2

[Step 2/3] Failed to execute goal
org.apache.maven.plugins:maven-release-plugin:2.5.3:prepare
(default-cli) on project **my-project-name**: Unable to commit files
Provider message: The git-push command failed. Command output: fatal:
remote error: Repository not found The requested repository does not
exist, or you do not have permission to access it.

我的父 pom 有以下 SCM 详细信息

<scm>
    <connection>scm:git:https://testurl.com:8081/scm/myrepo/${env.TEAMCITY_BUILDCONF_NAME}.git</connection>
    <developerConnection>scm:git:https://testurl.com:8081/scm/myrepo/${env.TEAMCITY_BUILDCONF_NAME}.git</developerConnection>
    <tag>1.0.0</tag>
</scm>

我的 bit-bucket 存储库名称、buildConfName 和工件 id 保持不变。当我构建父项目时,它运行成功,但是当我尝试构建子模块时,我看到 buildConfName 自动附加到父 POM 中配置的 SCM url

谁能告诉我为什么要添加额外的项目名称?

谢谢

【问题讨论】:

  • 你有提交权限吗?你是如何设置你的 git VCS 的?
  • 是的,正在使用的uesrname有提交权限。

标签: git maven teamcity maven-release-plugin


【解决方案1】:

经过一整天的努力,我发现了以下结果

  1. 我在所有其他项目中使用父 pom 来放置公共属性、公共构建步骤、公共依赖版本和 SCM 详细信息,因为所有项目都有点依赖关系,这实际上不是 maven 模块化项目。因此,在子 pom maven 中,在 scm 连接 url 中附加了工件 id,这在模块化项目方面是正确的行为。

  2. 而在 git 我的项目中,每个模块都有单独的存储库,而不是父项目的子目录。这会导致构建失败,因为由于 url 格式错误而找不到存储库。

所以我使用环境驱动属性来配置定义 scm 连接 URL,如下所示。

父 pom.xml 的变化如下

<profiles>

    <profile>
        <id>parent</id>
         <activation>
          <property>
            <name>scmModule</name>
            <value>parent</value>
          </property>
        </activation>
        <properties>
            <scmConnection>scm:git:https://testurl.com:8081/scm/**myrepo/my-parent.git**</scmConnection>
            <scmDeveloperConnection>scm:git:https://testurl.com:8081/scm/myrepo**/my-parent.git**</scmDeveloperConnection>
        </properties>
    </profile>

    <profile>
        <id>child</id>
         <activation>
          <property>
            <name>scmModule</name>
            <value>child</value>
          </property>
        </activation>
        <properties>
            <scmConnection>scm:git:https://testurl.com:8081/scm/**myrepo/**</scmConnection>
            <scmDeveloperConnection>scm:git:https://testurl.com:8081/scm/**myrepo/**</scmDeveloperConnection>
        </properties>
    </profile>

</profiles> 
<scm>   
    <connection>${scmConnection}</connection>
    <developerConnection>${scmDeveloperConnection}</developerConnection>
    <tag>1.0.0</tag>
</scm>

在运行构建时,我使用以下命令

用于构建父项目

 mvn release:prepare -DscmModule=parent 

用于构建子项目/模块

mvn release:prepare -DscmModule=child 

这解决了我关于子模块的问题,因为 maven 开始附加工件 id 并形成正确的 url

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-11-18
    • 2018-11-11
    • 1970-01-01
    • 1970-01-01
    • 2014-02-17
    • 2018-07-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多