#!/usr/bin/env python # This script will be invoked whenever a Perforce JOB is closed. # The Perforce trigger script invoking this script must pass the following parameters: # 1. Jira User id # 2. Jira Password (We used LDAP authentication for Perforce and JIRA. The passwords were stored in files accessible to root/user account running p4d service). # For example for user jaishu, the .passwd file would be stored in /home/jaishu/ # 3. This script will work only if Perforce and JIRA user ids and passwords are the same. import SOAPpy import getpass, datetime, sys soap = SOAPpy.WSDL.Proxy('http://localhost:8080/rpc/soap/jirasoapservice-v2?wsdl') print 'Arguments: ',sys.argv jirauser= sys.argv[1] passwd= sys.argv[2] #jirauser='admin' #passwd='admin' sys.argv.remove(jirauser) sys.argv.remove(passwd) print 'Jira user:',jirauser print 'Passwd:', passwd auth = soap.login(jirauser, passwd) for arg in sys.argv[1:len(sys.argv)]: issue = soap.getIssue(auth, arg) print 'Resolving issue..', issue['key'] # the state to which the JIRA ticket transitions will be indicated by the number after issue['key'] # If new states are added to the JIRA workflow, the integer value that should appear after the issue['key'] might change. # Check the Workflow under JIRA administration # the default "fixed" resolution has an id of 1, which is seen after "values" # the default close workflow action has an id of 2 soap.progressWorkflowAction(auth, issue['key'], '5' , [ {"id": "resolution", "values": "1" } ]) print "Done!"