Close JIRA Issues when Fixing Jobs in Perforce

Still need help?

The Atlassian Community is here for you.

Ask the community

Symptoms

The JIRA Fisheye plugin can create a corresponding perforce job for each issue. However when submitting fixes in perforce, the JIRA issue is not automatically closed as well.

Cause

There is a feature request for this functionality to be included with the plugin:

Resolution

The functionality is independent of the JIRA Fisheye plugin, and Perforce and JIRA already provide the requisite functionality to implement this.

Firstly you need to create a soap client that will call the JIRA remote API to close the issue. Here is a very rudimentary example in Python:

closeIssue.py
#!/usr/bin/python

import SOAPpy, getpass, datetime, sys

soap = SOAPpy.WSDL.Proxy('http://erdinger.sydney.atlassian.com:8080/rpc/soap/jirasoapservice-v2?wsdl')

jirauser='admin'
passwd='password'


auth = soap.login(jirauser, passwd)

for arg in sys.argv[1:len(sys.argv)]:

        issue = soap.getIssue(auth, arg)

        print 'Closing issue..', issue['key']

        # the default "fixed" resolution has an id of 1
        # the default close workflow action has an id of 2
        soap.progressWorkflowAction(auth, issue['key'], '2' , [
                {"id": "resolution", "values": "1" }
        ])

print "Done!"

This will be invoked as closeIssue.py <List of JIRA Issue Keys>.

Next we create a perforce fix trigger using p4 triggers. The trigger should look something like this:

Triggers:
        closeJira fix-add fix "/Users/amyers/closeIssue.py %jobs%"

Note that the assumption here is that all the jobs have an ID that corresponds to a JIRA issue key.

Caveats

  • The script should be modified to check for valid issue keys and handle perforce jobs that do not have a corresponding JIRA issue.
  • The script hardcodes resolutions/workflow action ids so it will not work with a custom resolution/workflow
  • This is not supported by Atlassian and is only provided as an example.

Last modified on Jul 31, 2018

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.