I'd like my Bitbucket Pipeline to control versioning of my Maven project.
Ideally, every time a change is made to the master branch, I want to create a new release and increment the version automatically.
Community moderators have prevented the ability to post new answers.
Hi
I have created a sample that shows how the Maven release plugin can be used in conjunction with Pipelines.
The Pipeline contains the following branches configuration:
master: - step: script: - git config --global user.email "$email" - git config --global user.name "$name" - mvn -batch-mode release:prepare -Dusername=$USERNAME -Dpassword=$PASSWORD -DscmCommentPrefix="[skip ci]" - mvn release:perform -Dgoals=install develop: - step: script: - mvn clean install
The DscmCommentPrefix argument ensures that the release prepare goal does not trigger an additional Pipelines build.
The release plugin require that the pom file contains the scm tag.
<scm> <url>https://example.com/pipelines-maven-sample</url> <connection>scm:git:https://example.com/pipelines-maven-sample.git</connection> <developerConnection>scm:git:https://example.com/pipelines-maven-sample.git</developerConnection> </scm>
You should use the maven release plugin version 2.5.3 or greater.
This sample assumes that all development is done in a development branch, when the development branch is considered stable it is merged to master.
Merging to master will run the maven release prepare and the release perform goals.
The release prepare goal will perform the following tasks:
Finally the release perform goal will:
The full sample can be seen at https://bitbucket.org/thomas_turrell/pipelines-maven-sample/overview
I hope that is useful for you.
Thanks Thomas, that was very helpful.
Especially the tip about: -DscmCommentPrefix=
"[skip ci]"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So, for $USERNAME, $PASSWORD, $name, and $email env vars, does that mean you created a BitBucket system user and injected all their creds as secure environment variables?
I would expect a better integration between Pipelines and BitBucket SCM, so I could just use settings and/or bitbucket-pipelines.yml to grant SCM Write access to a Pipelines executor without having to inject secure env vars.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes I inject the credentials.
I think you have three options for injecting the credentials:
You could probably use SSH keys as well.
Whatever option you choose you will have to trust everyone that has write access to the Git repo.
If you wanted to avoid injecting credentials then you could create your own Docker image but you would have to store it in a private repro (which isn't currently supported by pipelines).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.