问题
I am doing prepare release through Temcity using release-plugin I got below error
[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.
my parent pom have below SCM details
<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>
I kept my bit-bucket repository name , buildConfName and artifact id same. When i build the parent project it ran successfully , but when I ran tried to build the Child module I see buildConfName got appended automatically to the SCM url configured in Parent POM
Can anyone please tell why extra project name is added?
Thanks
回答1:
After doing a whole day efforts I found below findings
I am using parent pom in all my other project to just put common properties , common build steps , common dependency version and SCM details as all the project have dotted dependencies and which is not actually maven Modular project. So in child pom maven was appending the artifact id in the scm connection url which is correct behaviour in terms of modular project.
Whereas in git My project is having separate repository for each module and not the subdirectories to parent projects. this results in build failure as repository not found due to wrong url formation.
So I use environment driven properties to be configured for defining the scm connection URL as given below.
changes in the parent pom.xml as below
<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>
While running the build I am using below commands
for building the parent project
mvn release:prepare -DscmModule=parent
for building the child project/Module
mvn release:prepare -DscmModule=child
This resolves my issue as for child module as maven started appending artifact id and formed the correct url
来源:https://stackoverflow.com/questions/49896174/teamcity-prepare-release-failed-due-to-project-name-got-appended-to-fetch-url