user1256378
user1256378

Reputation: 742

create new project with Jira and python

Using Python 2.7, and jira-python package (version 1.0.4)

I tried this code:

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')

I get the error: File "/Library/Python/2.7/site-packages/jira/client.py", line 2357, in create_project for template in j['projectTemplates']: KeyError: u'projectTemplates'

When I look at the source: https://pythonhosted.org/jira/_modules/jira/client.html#JIRA.create_project

It seems like my project template is empty. My Jira user can create projects, and programmatically I can add issues.

Upvotes: 0

Views: 1846

Answers (1)

shrewmouse
shrewmouse

Reputation: 6050

The problem is with python-jira. Version 1.0.3 is failing. I upgraded to the development version using the following command:

$ 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

After upgrading I was able to create a project using python-jira

Upvotes: 1

Related Questions