Issue Tracking with Jira
Jira is a popular tool used to track issues, and rightfully so. With Jira, you can create custom workflows, fields, issues, reports, and more, giving it the ability to be configured for just about any projects need. You can also expand upon the integrations with Jira through Jira Apps. Some apps are paid, and some are free, but they all have different use cases to improve productivity. The issues that are tracked in Jira are related to a project, which will often have many issues. Jira can be used to track different kinds of projects, not just software development projects. There are a lot of customizable features that Jira offers along with its issue tracking capabilities. When working on projects, it can often be difficult to keep track of the different issues that can arise; Jira helps fill that gap. In the following sections, I’ll demonstrate how automation through Jenkins can be leveraged to create Jira tickets. Automating ticket creation can be useful, for instance, if a Jenkins build were to fail. If a build failed, you would automatically have a ticket to track any remediation efforts on that issue.
Configuring Jira Cloud
Atlassian provides a free cloud option if you stay within the user limits, which is great for those who just want to learn more about Jira. Setting up a Jira cloud instance is a breeze, there is no installation required, just some configurations for your own instance. To create issues in Jira from Jenkins, we’ll need to have some sort of authentication to Jira. For this reason, we will be creating what is called an API token in Jira, which basically acts as a password instead of using your actual password; this helps protect your password. Follow the below steps on how to get your Jira Cloud instance set up:
2. Setup an account with an email, username, and password
You will get an email that you will need to click a link to confirm
3. Navigate to https://www.atlassian.com/software/jira/free and click Next in the bottom right
4. Claim an instance
Skip any introductory questions if desired
5. Don’t add any additional people at this time
6. Select the Scrum Project type
7. Input a name for the project
8. Go to Atlassian Account Settings from settings drop down
9. Click Security > Create and manage API tokens
10. Click Create API Token
11. Input a label, click Create, then copy the API Token
Integrating Jira with Jenkins
Jenkins has the ability to integrate with Jira, allowing for automatic ticket creation from Jenkins builds. However, there are more advanced methods to create tickets as well, such as giving the Jenkins administrator the option to create a ticket depending on the outcome of a certain stage. To integrate Jenkins with Jira is quite straight forward but using it in practice can be a little more cumbersome if you aren’t familiar with the syntax. To configure the Jira plugin in Jenkins, do the following:
1. Login to Jenkins, if not already
2. Click Manage Jenkins > Manage Credentials
3. From the credentials page, select the Global drop down and click Add Credentials
4. Input your Jira cloud email along with the API token you copied from earlier for your password
5. Back in Manage Jenkins, go to Manage Plugins
6. Search for “jira pipe” in the Available tab. Once JIRA Pipeline Steps is selected, click install without restart
7. On the next screen, check the box to restart Jenkins when the installation is complete
8. Again, back in Manage Jenkins, go to Configure System
9. If you scroll down, you will now see a Jira Steps section. Click Add Site
10. Input a name for your Jira site and the base URL for your instance. Then, select the credentials created earlier
11. Lastly, go back to Manage Jenkins and Click Manage Nodes and Clouds
12. From there, click the gear icon on the far right of the Master node
13. Then, add four environment variables that are used in the next section for the test; change these environment variables as needed for your environment
Variables:
Name: JIRA_CLOUD
Value: [Jira_Cloud_Name]
Name: JIRA_PROJECT
Value: [Jira_Project_ID]
Name: REMOTE_NODE
Value: [IP_of_Ubuntu_Node]
Name: USER
Value: [Username]
A Quick Test
This last section before we wrap up, we will make sure everything is working as expected. There is a GitHub repository that I created, which will be leveraged to test all of the components. All that is needed is to create a Pipeline job in Jenkins and point to the GitHub repository. If everything was configured correctly, when we run the build, we shouldn’t get any failures. 1. Select New Item from the left on the Dashboard
2. Input a name for the Job and select Pipeline
3. Scroll down to the bottom and input the required information.
NOTE: Credentials are not needed as this is a public repository
Parameters:
Definition: Pipeline script from SCM
SCM: Git
Repository URL: https://github.com/zthurmond/first_devops_lab_blog
4. Select Build on the left and you should see it run successfully
5. Also, if you check in Jira under backlog, you should see a new issue created
NOTE: This job will always create a Jira issue, regardless if it succeeded or failed. The purpose of this is to test that you have setup everything correctly and Jenkins can successfully create a Jira issue
Final Words
This five-part series is officially at an end. We have covered so many different components in this lab build to get you started, but it is really up to you what you do with it. Putting in the time to learn new components will allow you to provide more value to a potential future employer, or your current one. DevOps is a popular field right now and there is a large need for DevOps engineers. Not only knowing how to use these components is important, but also knowing how they can solve your businesses problems. We haven’t gone too in depth on any of these products, mainly just focusing on the setup. For that reason, I have included links below to resources that will help you learn and use these tools. Resources:
Jenkins:
Jira:
Docker:
Splunk:
Ansible:
Sites with Useful Courses on DevOps:
Comments