The aim of the article is to make a short guide on how to setup a simple Jira plugin development process using SonarCube, Jacoco , Bitbucket and Bitbucket pipelines. All of the mentioned tools are free of charge. Bitbucket pipeline offers you 50 free minutes per month to run your pipeline.
A few words on each tool.
SonarCube is a tool for code quality inspection. It can detect bugs, code smells and security vulnerabilities in your code.
Jacoco is a code coverage tool, which lets you measure how much of your code covered by unit tests.
Bitbucket is a web-based hosting service, which is used for managing source code.
Bitbcket pipeline is a continuous integration tool.
The tools above will help you to develop a higher quality software.
Ok. Let's move to the guide section.
1. Create Bitbucket account on https://bitbucket.org/
2. Setup SonarCube.
2.1. Create a SonarCube account on https://sonarcloud.io/. Use your bitbucket account to authenticate in SonarCube.
2.2. Create a new organization called tutorial in https://sonarcloud.io/account/organizations
2.3. Generate a new security token in https://sonarcloud.io/account/security/
3. Install Atlassian SDK and create your first servlet Jira plugin.
I will make a short list of what should be done. You can find a more detailed explanation here:
3.1. Download Atlassian SDK.
3.2. Create a folder for storing your Jira plugins and execute the following command within the folder:
Enter com.atlassian.tutorial for the groupId and ciprocess for the artifactId. Then press several times “Enter” and type Y when you are asked if you want to create the plugin.
3.3. Go down to the ciprocess folder (cd ciprocess) and execute the following command:
When you are asked to choose a number you should choose 21. Number 21 means that the Servlet module will be created for you plugin. When you are asked questions about the servlet class name and package press enter. When you are asked “Show advanced setup” press N. When you are asked “Add Another Plugin Module” press N.
3.4 Run the plugin with the following command
After Jira started you can go to the following url in your browser:
And you will see the “Hello World” message.
4. Connect Jacoco.
4.1. Add the following lines into the <build><plugins> section of the pom.xml file:
4.2. Add the following lines into <properties> section of the pom.xml file:
Change sonar.login variable with the security token which you received in 2.3.
4.3. Create .gitignore file in the plugin directory with the following content
# Compiled class file
# Log file
# BlueJ files
# Mobile Tools for Java (J2ME)
# Package Files #
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
# User-specific stuff:
# Sensitive or high-churn files:
# Mongo Explorer plugin:
## File-based project format:
## Plugin-specific files:
# mpeltonen/sbt-idea plugin
# JIRA plugin
# Cursive Clojure plugin
# Crashlytics plugin (for Android Studio and IntelliJ)
5. Put the source code to a bitbucket repository.
5.1. Sign in to your Bitbucket account
5.2. Create a new repository with GIT version control and name it “ciprocess”.
5.3. Install on your computer GIT client.
5.4. Open terminal, go to your plugin folder and initialize a git repo with the following command:
5.5. Add all files to the local repo by executing
git add *
git commit -m “initial commit”
5.4. Push your source code to the repo in Bitbucket. On the overview page of your created repository in bitbucket.org you will see instructions on how to put your source code into your repository. In my case instructions look like this
Step 1: Switch to your repository's directory
Step 2: Connect your existing repository to Bitbucket
git remote add origin https://email@example.com/alex1mmm/ciprocess.git
git push -u origin master
Follow the instructions, which you can see in the overview page of your bitbucket repository.
6. Create bitbucket pipeline.
6.1. Go to your repository in Bitbucket.org and choose Pipelines menu.
6.2. Create pipeline for Java language. bitbucket-pipelines.yml should look like this:
script: # Modify the commands below to build your repository.
- atlas-mvn -X clean package sonar:sonar # -B batch mode makes Maven less verbose
You can read more about creating bitbucket pipeline here:
7. Upon new pushes to the repository the pipeline will build your module and create the build report in SonarCube.
You can see the build report here:
If you need the source code of the plugin you can get it here:
Alexey MatveevCommunity Champion
Hello Atlassian Community! My name is Ada , and I'm the Product Marketing Manager for Confluence Server at Atlassian. If you missed our last post, we're transitioning to quarterly updates&nb...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs