I am using the JIRA Python module which is an extension of the REST API to automate the process of deleting and creating issues in JIRA. I am trying to create issues in JIRA using a 'for' loop in my python script that uses imported data that I have collected from another database. I need to format the fields when creating the issue so the data I have can align properly with the appropriate fields in JIRA. My Python code is below for creating the issues and storing the data to put into JIRA which is being stored in custom variables:
df contains 13 columns of data that I want to input into JIRA by creating new issues. Each column represents a different field for an issue in JIRA. Every new issue created in JIRA should get info from each column:
from jira.client import JIRA
import pandas as pd
# Now we input the issues from the export.csv CSV file into the fields
# of new issues that are being created in JIRA to replace the old ones that were
# deleted
df = pd.read_csv('C:\\Python27\\scripts\\export.csv')
# Set the column names from the export.csv file equal to variables using the
# pandas python module
# Now do the actual loop to create new issues
for row in df:
cqid = df['ClearQuest ID']
summ = str(df.Summary)
datecreated = df['Date Created']
dateresolved = df['Date Resolved']
wistate = df['WI State']
res = df.Resolution
affected = df['Affected version/s']
fixed = df['Fix version/s']
issue_type = df['Issue Type']
priority = df.Priority
comments = str(df.Comments)
jira.create_issue(project={'key': 'DEL'}, wistate={'customfield_1001': 'WI State'}, res={'customfield_1001': 'Resolution'}, cqid={'customfield_1001': 'ClearQuest ID'}, datecreated={'customfield_1001': 'Date Created'}, dateresolved={'customfield_1001': 'Date Resolved'}, priority={'customfield_1001': 'Priority'}, fixed={'customfield_1001': 'Fixed Version'}, affected={'customfield_10004': 'affected'}, summary=summ, description=comments, issuetype={'name': 'Defect'})
It gives the error:
JIRAError: HTTP 400: "{u'cqid': u"Field 'cqid' cannot be set. It is not on the appropriate screen, or unknown.", u'wistate': u"Field 'wistate' cannot be set. It is not on the appropriate screen, or unknown.", u'dateresolved': u"Field 'dateresolved' cannot be set. It is not on the appropriate screen, or unknown.", u'res': u"Field 'res' cannot be set. It is not on the appropriate screen, or unknown.", u'datecreated': u"Field 'datecreated' cannot be set. It is not on the appropriate screen, or unknown.", u'affected': u"Field 'affected' cannot be set. It is not on the appropriate screen, or unknown.", u'fixed': u"Field 'fixed' cannot be set. It is not on the appropriate screen, or unknown."}"
Here is some example data that is showing up in JIRA for every single issue created in the comments field:
Issue 1:
0 NaN
1 Found that the Delta would leak packets receiv...
2 The Delta will reset everytime you disconnect ...
3 NaN
4 It's supposed to get logged when CP takes to l...
5 Upon upgrading the IDS via the BioMed menu, th...
6 Upon upgrading the IDS via the BioMed menu, th...
7 Upon upgrading the IDS via the BioMed menu, th...
8 Increased Fusion heap size and the SCC1 Initia...
9 Recheck using build 142+, after Matt delivers ...
10 When using WPA2, there is EAPOL key echange go...
11 When using WPA2, there is EAPOL key echange go...
12 NaN
13 NaN
14 NaN
...
I only want each issue to have its own string values, and not the index numbers or the NaN to show up like this:
Issue 1:
Issue 2: Found that the Delta would leak packets receiv...
Issue 3: The Delta will reset everytime you disconnect ...
...
for row in df.itertrows(), see here: pandas.pydata.org/pandas-docs/dev/basics.html#iterationdf.iterrows()