What’s up Guys! Welcome to automationcalling.com

This post is mainly helps for DevOps Engineer who want to integrate their Deployment task end result with JIRA. The JIRA is globally recognized tool for tracking requirements (Story), defects, task as part of Software development practice. In fact some companies directly create PROD defects in JIRA after investigation, some companies have their own or third party software for support activities where JIRA plugins integration. Hence, the same approach we will see in this blog for deployment activities in Jenkins with JIRA plugin and how to use the snippet of code to create task for DevOps deployment end results.

Disclaimer Note: This post is applicable for Jenkins – JIRA Integration requirement.

There are many reason to integrate JIRA Plugins in Jenkins

  • To Monitor Success/Failure Deployment on PROD or PREPROD.
  • To help audit for necessary deployment task automatically created for each releases.
  • To track test automation success/failures in each deployment and automatic bug creation for Continuous improvement as part of CI/CD practice.
  • To track detail metrics for each release and its component in JIRA Dashboard., for eg.,
    • How many deployments for each release version in module wise.
    • How many releases and how many modules/job for each releases in monthly, quarterly or yearly.

Pre-requisities:

  • Install JIRA Pipeline plugin for JIRA integration in Jenkins: https://plugins.jenkins.io/jira-steps/
  • In Jenkins, Go to Configure System -> The installed plugin will be visible
    • Add your Jenkins Server Name, Server URL, Connection Timeout and Authentication support you want to add like Basic, OAuth or Credentials
  • You must have a pipeline setup ready for your deployment job, in your post successful/failure depends on your condition use the following snippet of code.

CODE SNIPPET:

node {
  stage('JIRA') {
    withEnv(['JIRA_SITE=JIRA_Server']) {  
    def testIssue = [fields: [ // id or key must present for project.
                               project: [key:'XXX'],
                               summary: 'NAME OF MODULE OF DEPLOYMENT OR JENKINS JOB NAME',
                               description: 'REPLACE WITH YOUR DESCRIPTION HERE',
                               fixVersions:[[name:'1.0']],
                               labels:['PRODUCTION-DEPLOY'],
                               // id or name must present for issueType.
                               issuetype: [id: '3']]]
     
    response = jiraNewIssue issue: testIssue
 
    echo response.successful.toString()
    echo response.data.toString()
 
  }
}
}

If you look at the above example, the post script will create automatic task for you based on your condition specified post build in Jenkins. You may use issue type ID like 1, 2, 3 or depends on your requirement and index setup in your organization.

Hope! this post may helpful to you guys. Thanks for your time, please do subscribe for more updates!

Reference: https://jenkinsci.github.io/jira-steps-plugin/index.html

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s