4
执行JIRA过渡如何标记JIRA问题为解决或通过其REST API使用Python的(第2版)收盘?通过Python REST API
我发现的文件在http://docs.atlassian.com/jira/REST/latest/#id199544但我有各种错误包括:
- HTTP错误415:不支持的媒体类型
- HTTP错误400
执行JIRA过渡如何标记JIRA问题为解决或通过其REST API使用Python的(第2版)收盘?通过Python REST API
我发现的文件在http://docs.atlassian.com/jira/REST/latest/#id199544但我有各种错误包括:
搜索了很长一段时间,我发现后该解决方案,我在这里发布的任何其他人谁有兴趣使Git/Gerrit钩做像我这样的事情:
首先在您的浏览器中打开http://example.com/rest/api/2/issue/<ISSUE>/transitions?expand=transitions.fields
以查找您的网站和问题编号以查找转换ID。
假如这是1000:
import urllib
import urllib2
import base64
import json
key = 'JIRA-123'
comment = "It's done!"
username = 'username'
password = 'password'
# See http://docs.atlassian.com/jira/REST/latest/#id199544
url = 'http://example.com/rest/api/2/issue/%s/transitions' % key
auth = base64.encodestring('%s:%s' % (username, password)).replace('\n', '')
data = json.dumps({
'transition': {
'id': 1000 # Resolved (for my setup)
},
'update': {
'comment': [
{
'add': {
'body': comment
}
}
]
},
})
request = urllib2.Request(url, data, {
'Authorization': 'Basic %s' % auth,
'Content-Type': 'application/json',
})
print urllib2.urlopen(request).read()
您可以完全忽略注释部分,如果你不希望添加评论。