Close JIRA Issues when Fixing Jobs in Perforce

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

症状

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.

原因

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

ソリューション

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.

注意事項

  • 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.

最終更新日 2018 年 7 月 31 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.