1

Using Jenkins with Maven (2 or 3) build system, is there a way to:

*Express a release to another environment (say UAT), and to update JIRA tickets that are in one state (waiting for UAT release) to another state (ready for UAT)?

M2 Release Plugin seems like an easy answer for the statement of release, but as to updating JIRA tickets, can't quite find a solution to help automate the approach.

Looking for feedback if someone has accomplished a task like this!

Similar questions: What are the options for release management using Jenkins

individual ticket trigger versus 'version' triggering...would be way cool to simply trigger a 'release' once all tickets of a particular JIRA ticket type reach a status of 'waiting for UAT release' within a version. Is there a way to trigger a Jenkins job based on the status of a JIRA ticket?

JIRA plugin for Jenkins jira update ticket using script https://wiki.jenkins-ci.org/display/JENKINS/JIRA+Plugin

Community
  • 1
  • 1
dhartford
  • 1,125
  • 2
  • 12
  • 35

1 Answers1

2

This is a solution I implemented to update and transition an issue with the related artifacts the jenkins job distributed to our artifact repository.

I used the python JIRA module to do accomplish this. You can find more info here:

https://jira-python.readthedocs.org/en/latest/

I call this python script as a build step at the end of the container job that does the build.

This requires you define a JIRA workflow for your issues that has a transition that performs the appropriate functionality (transitioning issue from one state to another.)

from jira.client import JIRA

def add_artifacts_and_transition_ticket(issue, artifact_urls):
    """ write our urls to the jira ticket provided
    by jenkins and mark issue as Release Candidate in Test """

    jira = JIRA(options={'server': 'https://myjiraserver', 'verify':False},
            basic_auth=('jira_username', 'somePassword'))
    issue = jira.issue(issue)

    # add the artifacts urls to the jira ticket
    jira.add_comment(issue, 'A new RC artifact set is now available:\n' + '\n'.join(artifact_urls))

    # transition the issue from Create Release 
    # Candidate to Release Candidate In Test
    #'161' is the unique id of the my jira workflow transition
    # your transition ID will probably differ.
    # "Create Release Candidate", defined by jira admin

    jira.transition_issue(issue, '161')

if __name__ == '__main__':
    # sample call
    artifact_urls = ['url1', 'url2']
    issue = 'PROJECT_FOO-99999'
    add_artifacts_and_transition_ticket(issue, artifact_urls)
ablarg
  • 2,400
  • 1
  • 24
  • 32
  • Ah, so 161 is the workflow_transition ID (for ablarg's jira workflow, it will be different for someone else), not the project ID, correct? I'm not a python guy, but I'll see if I can squeeze some time in to try this approach you shared, thanks! – dhartford Jan 29 '15 at 18:55
  • yes, 161 is the workflow transition -- it will be different since each transition has its unique ID created by JIRA when you committed the transition scheme. – ablarg Jun 09 '15 at 17:15