mvn release:prepare and release:perform with BitBucket

Whilst many people might find this is easy, I think I have google zillions of page just to get a simple mvn release:prepare and mvn release:perform with BitBucket.

I thought I am going to write a blog here just to help out those you might need a dummy-guide to get maven prepare and perform working.

Please note that I am using Linux, and also running the command with Netbeans.

The public Key

  • Firstly, do a sudo apt-get install git
  • The next thing we need to do is to identify WHO you are, and that is done by generating public key, and then install in on BitBucket.
  • Open another terminal
  • Generate with command ssh-keygen
  • Enter, enter passphrase etc, etc, just follow it. Until the key is generated.
  • You will see similar image like this one — I just took Atlassian sample (Atlassian, 2015a):
    $ ssh-keygen 
    Generating public/private rsa key pair.
    Enter file in which to save the key (/Users/emmap1/.ssh/id_rsa):
    Created directory '/Users/emmap1/.ssh'.
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /Users/emmap1/.ssh/id_rsa.
    Your public key has been saved in /Users/emmap1/.ssh/
    The key fingerprint is:
    4c:80:61:2c:00:3f:9d:dc:08:41:2e:c0:cf:b9:17:69 emmap1@myhost.local
    The key's randomart image is:
    +--[ RSA 2048]----+
    |*o+ooo.          |
    |.+.=o+ .         |
    |. *.* o .        |
    | . = E o         |
    |    o . S        |
    |   . .           |
    |     .           |
    |                 |
    |                 |


  • You then need to access your BitBucket, go to avatar > Manage account and then click on SSH Keys. Again I took this example from Atlassian article (Atlassian, 2015b)

The ‘release’ branch

When we perform a release, of course we need to create a branch where the artifacts being uploaded. So, go and login to your BitBucket and create a branch and call it 'releases'.

Modify pom.xml

What needs to be done next is to modify our pom.xml to point to the correct BitBucket account. Bear in mind that our git can now identify WHO we are since we have do the 'public key work in the previous section.

In order to deploy artifacts on remote Git SCM repository, we need to use a plugin called wagon-git (Synergian, 2015).

The website provided in Synergian is very detail. Feel free to follow it. But I am going to show you snippet of my pom.xml anyway. comments interleaved.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">

    <!-- FIRSTLY, add this. Please refer to Synergian documentation -->

        SECONDLY, you need to add your repository location. Just replace the one below
        particularly on 'dwuysan/lucyhr-api'.

        distributionManagement, it needs to point to the 'releases' branch we created. Pay attention to

    <!-- Again, make the changes accordingly to your own path -->

            So that we can perform mvn:release prepare and mvn:release perform, we need to add
            maven-release-plugin. That one is quite basic.


            remember to add wagon-git

That’s it! You can do now mvn:release prepare and mvn:release perform, with your released artifacts uploaded to BitBucket.


Atlassian, 2015a, ‘Set up SSH for Git’, Atlassian, accessed on 27 October 2015

Atlassian, 2015b, ‘Add an SSH key to an account’, Atlassian, accessed on 27 October 2015

Synergian, 2015, ‘wagon-git’, Synergian, accessed on 27 October 2015