Created
March 19, 2010 20:30
-
-
Save jmcmellen/338140 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Create a new issue in Jira from the Python XMLRPC interface. You'll have to | |
#provide the server and user credentials and match up your own fields | |
import sys | |
from xmlrpclib import Server | |
user = "username" | |
passwd = "passwd" | |
serverurl = "https://server.example.com/rpc/xmlrpc" | |
projectname = "demoproject" | |
s = Server(serverurl) | |
auth = s.jira1.login(user, passwd) | |
#Search for existing issues | |
issuetable = s.jira1.getIssuesFromTextSearch(auth, "test") | |
print issuetable | |
#Get a specific issue by ID | |
anotherissue = s.jira1.getIssue(auth, "ExampleIssueID1") | |
print anotherissue | |
#Create a new issue and add some comments | |
newissue = s.jira1.createIssue(auth, {'project': projectname, 'type': '3', | |
'summary':'Issue Created via XML-RPC epsilon', | |
'description':'Created with Python client again again', | |
'environment':'Windows 7/Python 2.6', | |
'components':[{'name': 'componentname', 'id': '10111'}], | |
'customFieldValues': [{'customfieldId': 'customfield_10012', 'values': ['10020']}, | |
{'customfieldId': 'customfield_10012', 'values': ['10060'], 'key': '1'}, | |
{'customfieldId': 'customfield_10018', 'values': ['Thing']}, | |
{'customfieldId': 'customfield_10001', 'values': ['More Text']}], | |
}) | |
print "Created %s/browse/%s" % (s.jira1.getServerInfo(auth)['baseUrl'], | |
newissue['key']) | |
print "Commenting on issue.." | |
s.jira1.addComment(auth, newissue['key'], 'Comment added with XML-RPC') | |
print "Modifying issue..." | |
s.jira1.updateIssue(auth, newissue['key'], { | |
"summary": ["[Updated] issue created via XML-RPC"], }) | |
print "Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment