Close JIRA Issues when Fixing Jobs in Perforce

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 #!/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:

1 2 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.

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.