How do I get the maven release plugin to work with bitbucket pipelines?
Our pipeline is utilizing BITBUCKET_GIT_HTTP_ORIGIN for the configuration of the release with the following steps:
mvn -B release:prepare
mvn -B release:perform
mvn release:prepare works correctly and updates versions and commits it back to origin. However, the release:perform step fails with the following error:
[ERROR] Cloning into '/opt/atlassian/pipelines/agent/build/target/checkout'...
[ERROR] fatal: could not read Username for 'https://bitbucket.org': No such device or address
The clone command it is trying to run:
[INFO] Executing: /bin/sh -c cd /opt/atlassian/pipelines/agent/build/target && git clone --branch v1.0.8 <private-project-url-removed> /opt/atlassian/pipelines/agent/build/target/checkout
The url that it is using is the same from the other bitbucket commands that were executed from the release:prepare step.
The easiest way to configure your SCM correct in your pom.xml is by using the environment variables that bitbucket-pipelines sets.
<scm>
<connection>scm:git:${env.BITBUCKET_GIT_HTTP_ORIGIN}</connection>
<url>${env.BITBUCKET_GIT_HTTP_ORIGIN}</url>
<developerConnection>scm:git:${env.BITBUCKET_GIT_HTTP_ORIGIN}</developerConnection>
</scm>
To avoid the clone problem when running the relase:perform use the option localCheckout such as in the example using the command line:
mvn -B -s settings.xml -DlocalCheckout=true release:perform
To avoid the prepare commits from triggering other pipelines use the option scmCommentPrefix from the release plugin, with the "[skip ci]" content, in the command line or in the pom.xml configuration block like the example below:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>3.0.0-M1</version>
<configuration>
<tagNameFormat>version/@{project.version}</tagNameFormat>
<scmCommentPrefix>[skip ci] [maven]</scmCommentPrefix>
</configuration>
</plugin>
This way the two commits won't trigger the pipeline.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Zachary,
Are you sure the url is identical? In particular, check to make sure that it is a "http" url and not a "https" url. Git operations against origin go via a local proxy (running alongside your build container and only accessible to your build) and if you look at the value of BITBUCKET_GIT_HTTP_ORIGIN you'll see that it uses the plain, unsecured "http" protocol. The proxy establishes a secure "https" connection when it talks to the real server.
(This all assumes that you're connecting to the origin server of your main repository, which it seems like you are doing. If I've misunderstood and you're actually trying to connect to another repository or another server then that connection won't be using the local proxy. It should use a secure protocol and it will require that you set up authentication manually).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes I am sure it's using http. Like I said, the 'prepare' phase is working correctly which pushes commits back to the original repo.
Our team will be moving away from bitbucket for our CI solution. We have spent too much time already trying to get around the bugs.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You should use the exactly url show in BITBUCKET_GIT_HTTP_ORIGIN, example
http://bitbucket/[user]/[project]
NOT
https://bitbucket/[user]/[project].git
https://bitbucket/[user]/[project]
http://bitbucket/[user]/[project].git
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Miuler I'm facing a very similar issue during the `maven prepare` when it is trying to push:
fatal: could not read Username for 'https://bitbucket.org': No such device or address
What do you mean by your response above? Are you saying that in the `pom.xml` we must not use https for the `scm` tag. Like this?
<scm> <connection>scm:git:http://bitbucket.org/[company]/[project].git</connection> <developerConnection>scm:git:http://bitbucket.org/[company]/[project].git</developerConnection>
<url>http://bitbucket.org/[company]/[project]</url>
<tag>HEAD</tag>
</scm>
I'm able to get this to work flawlessly with `https` from my local machine. But this seems to be not a well-documented process from bitbucket pipelines.
Could someone provide a sample bitbucket-pipelines.yml file? It seems you must provide a command that does not trigger an infinite loop:
git remote set-url origin ${BITBUCKET_GIT_HTTP_ORIGIN}
mvn -B -Dmaven.test.failure.ignores -f pom.xml release:clean release:prepare release:perform -DscmCommentPrefix="[skip ci]"
But what do before this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There are an amazing variety of answers out there for getting maven release to work, but none that seem to be complete and/or work.
This was the best example I could find:
It is is not complete either, but comes close to working.
Other issues to consider,
git remote set-url origin ...
From: bitbucket-pipelines <commits-noreply@bitbucket.org>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.