I am trying to do mvn release:prepare
on a multi-module project which is hosted on a Gitlab server.
The pom.xml
for my master POM contains:
<scm>
<connection>scm:git:http://my-git-server.example.com/git/somebody/my-project.git</connection>
<url>http://my-git-server.example.com/git/somebody/my-project</url>
</scm>
When I do mvn release:prepare -DautoVersionSubmodules=true
, it compiles everything and runs the test, but then fails with:
[INFO] Executing: /bin/sh -c cd /home/somebody/git/my-project && git tag -F /tmp/maven-scm-1594218362.commit my-project-1.0.0
[INFO] Working directory: /home/somebody/git/my-project
[INFO] Executing: /bin/sh -c cd /home/somebody/git/my-project && git push http://my-git-server.example.com/git/somebody my-project-1.0.0
[INFO] Working directory: /home/somebody/git/my-project
...
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.3.2:prepare (default-cli) on project iwes-lib-master: Unable to tag SCM
[ERROR] Provider message:
[ERROR] The git-push command failed.
[ERROR] Command output:
[ERROR] fatal: repository 'http://my-git-server.example.com/git/somebody/' not found
[ERROR] -> [Help 1]
So it is telling me the maven-release-plugin thinks that the parent directory to my Git repository is the repository, bailing out there.
Adding a developerConnection
does not help.
When trying to use SVN, it fails with "Access Denied:
<scm>
<connection>scm:git:http://my-git-server.example.com/git/somebody/my-project.git</connection>
<developerConnection>ssh://[email protected]:10022/somebody/my-project.git</developerConnection>
<url>http://my-git-server.example.com/git/somebody/my-project</url>
</scm>
gives me:
[INFO] Executing: /bin/sh -c cd /home/jra/Documents/git/my-project && git push ssh://[email protected]:10022/somebody my-project-master-1.0.0
....
[ERROR] Access denied.
So, it, again, uses the parent directory.
How do I force the release plugin to use the real URL I state there?
I ran in the same issue with a call like that
mvn deploy scm:tag
I'm using a gitlab installation and it also don't allow calls like this
[INFO] Executing: /bin/sh -c cd /home/user/prog/gitlab/test-user_server && git tag -F /tmp/maven-scm-482134407.commit test-user_server-1.1-SNAPSHOT
[INFO] Working directory: /home/user/prog/gitlab/test-user_server
[INFO] Executing: /bin/sh -c cd /home/user/prog/gitlab/test-user_server && git push [email protected]:testplus/test-user_server.git refs/tags/test-user_server-1.1-SNAPSHOT
[INFO] Working directory: /home/user/prog/gitlab/test-user_server
[ERROR] Provider message:
[ERROR] The git-push command failed.
[ERROR] Command output:
[ERROR] Permission denied, please try again.
The problem is this call
/bin/sh -c cd /home/user/prog/gitlab/test-user_server && git push [email protected]:testplus/test-user_server.git refs/tags/test-user_server-1.1-SNAPSHOT
But this call is not really necessary, because I start the mvn in the root of my git repository. Instead a command line call like the one below works.
git push origin refs/tags/test-user_server-1.1-SNAPSHOT
So I modified my scm configuration inside my pom.xml to a string like the following and it works for me like a charm.
<scm>
<developerConnection>scm:git:origin</developerConnection>
</scm>
I develop under a Linux OS and so I have not tested if it works also on Windows system.
As some have said, those workaround can make work the prepare phase of the release but not the perform phase (in my case that was it). I finally managed to have a full release working by finding the correct way to enter the data to put the developperConnection tag :
<scm>
<developerConnection>scm:git:[email protected]:groupProject/project.git</developerConnection>
<tag>HEAD</tag>
</scm>
Many other URL format were accepted in my case but in the end failed during the perform or prepare phase of the release (scm:git:ssh://git@gitlab... for instance was having this problem). I don't know if this solution is specific to Gitlab or maybe my project but I spent a lot of time finding this workaround...
EDIT: The workaround I proposed here does not work for release:perform
, in fact, I did not find a feasible solution till today. I am now doing the release manually as I will describe below.
I investigated on this issue some more and I think it is a bug. I filed a JIRA for it: MRELEASE-900
I dumped maven-release-plugin
and am now doing the release manually the following way (example: release 1.3.0, snapshot version is 1.3.0-SNAPSHOT):
git checkout master && git pull
just to be suregit checkout -b release-1.3 && git push -u origin release-1.3
cd path/to/my/master/project
mvn versions:set
, it asks me to specify the new version for 1.3.0-SNAPSHOT
, I enter 1.3.0
git commit -a
so the new version is checked-ingit tag release-1.3.0
git push && git push --tags
- At this point, there is a tag release-1.3.0
in the branch release-1.3
where all relevant POM version numbers are 1.3.0
git checkout master
git merge release-1.3
- do not commit yet, I first update the versions.mvn versions:set
, set new SNAPSHOT version, as per my convention, this would be 1.4.0-SNAPSHOT
git commit -a
git push
I can then create a Jenkins job or what I like on the tag release-1.3.0
to process the release.
-- Old answer for reference below --
After poking around and trying various things, I made some progress: I have to let the maven-release-plugin think that my-project.git
is a directory and add a faux file to the URL.
The following works:
<scm>
<connection>scm:git:http://my-git-server.example.com/git/somebody/my-project.git/.git</connection>
<developerConnection>scm:git:http://my-git-server.example.com/git/somebody/my-project.git/.git</developerConnection>
<url>http://my-git-server.example.com/git/somebody/my-project</url>
</scm>
And the same with tSSH:
<scm>
<connection>scm:git:http://my-git-server.example.com/git/somebody/my-project.git/.git</connection>
<developerConnection>ssh://[email protected]:10022/somebody/my-project.git/.git</developerConnection>
<url>http://my-git-server.example.com/git/somebody/my-project</url>
</scm>
Now release:prepare
works, but release:perform
fails because it wants to download from ssh://[email protected]:10022/somebody/my-project.git/.git
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With