使用Jira和python创建新项目

时间:2016-04-12 03:33:00

标签: jira jira-rest-api python-jira

使用Python 2.7和jira-python包(版本1.0.4)

我试过这段代码:

from jira.client import JIRA
user     = 'admin'
password = 'xxx'
server   = 'https://xxx.atlassian.net'
jira = JIRA(basic_auth=(user, password), options={'server': server})    
projname       ="ProjetCreatedFromPython"
projkey        ="PROJPYTHON"
projassignee   =user

#Problem line - I've tried leaved "Scrum" empty and used a few different variations.  
jira.create_project(projkey, projname, projassignee, 'Scrum')

我在create_project中收到错误:文件“/Library/Python/2.7/site-packages/jira/client.py”,第2357行     对于j ['projectTemplates']中的模板: KeyError:u'projectTemplates'

当我查看来源时:https://pythonhosted.org/jira/_modules/jira/client.html#JIRA.create_project

好像我的项目模板是空的。我的Jira用户可以创建项目,并且我可以通过编程方式添加问题。

1 个答案:

答案 0 :(得分:1)

问题在于python-jira。版本1.0.3失败。我使用以下命令升级到开发版本:

$ pip install 'jira==1.0.7.dev20160607111203' --force-reinstall
Collecting jira==1.0.7.dev20160607111203
  Downloading jira-1.0.7.dev20160607111203-py2.py3-none-any.whl (58kB)
Requirement already satisfied (use --upgrade to upgrade): requests-toolbelt in c:\python27\lib\site-packages (from jira==1.0.7.dev20160607111203)
Requirement already satisfied (use --upgrade to upgrade): requests-oauthlib>=0.3.3 in c:\python27\lib\site-packages (from jira==1.0.7.dev20160607111203)
Requirement already satisfied (use --upgrade to upgrade): requests>=2.6.0 in c:\python27\lib\site-packages (from jira==1.0.7.dev20160607111203)
Requirement already satisfied (use --upgrade to upgrade): six>=1.9.0 in c:\python27\lib\site-packages (from jira==1.0.7.dev20160607111203)
Requirement already satisfied (use --upgrade to upgrade): tlslite>=0.4.4 in c:\python27\lib\site-packages (from jira==1.0.7.dev20160607111203)
Requirement already satisfied (use --upgrade to upgrade): oauthlib>=0.6.2 in c:\python27\lib\site-packages (from requests-oauthlib>=0.3.3->jira==1.0.7.dev20160607111203)
Installing collected packages: jira
  Found existing installation: jira 1.0.3
    Uninstalling jira-1.0.3:
      Successfully uninstalled jira-1.0.3
Successfully installed jira-1.0.7.dev20160607111203

升级后,我可以使用python-jira

创建项目