Have the following method to pull data from a csv to write create a Jira issue. I first create issue with Summary and Description. I then want to update the issue to include the Feature ID field(type is label). I also want to update the Labels field with "tags" column from the csv.(importing from Rally csv into Jira)
Does featureid need to be converted to a list, then passed into the update?
for row in df2.iterrows():
summ = str(df2.loc[row[0], 'Summary'])
desc = str(df2.loc[row[0], 'Description'])
#These have to be updated
featureid = str(df2.loc[row[0], 'Feature ID'])# customfield_10007, type is label
#owner = str(df2.loc[row[0], 'Assignee']) # need to update usernames or have a lookup
tags = str(df2.loc[row[0], 'Labels']) # Needs to return an array
try:
jira_options = {'server': jira_url}
jira = JIRA(options=jira_options, basic_auth=(jira_user, jira_password))
log.info("Connecting to JIRA: %s" % jira_url)
#customfield_10007=featureid, assignee=owner, description=desc, labels=tags,
issue = jira.create_issue(project={'key': jira_project_key},
summary = summ,
description = desc,
issuetype = {'name': jira_issue_type})
print issue ,'was created.'
issue.update(customfield_10007={'Feature ID':featureid}) #need to convert to list before I can update?
except JIRAError, e:
log.error("Failed to connect to JIRA: %s" % e)
print "Failed to connect to JIRA ",e
return None
This worked. Thanks for the help everyone.
issue.update(fields={"customfield_10007":featureid.split()}) issue.update(fields={"labels":tags.split(';')})
Try this instead:
issue.update(fields={"customfield_10007":featureid})
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If I could, I would, but it might also be helpful for us if you surrounded your code in using the code macro (click the <> button when you edit your answer).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
def getdatafromcsv(): mycols = ['Formatted ID', 'Name', 'Owner', 'Description', 'Tags'] df = pd.read_csv(mycsv) df1 = df[mycols] df2 = df1.rename(columns={'Name': 'Summary', 'Formatted ID': 'Feature ID', 'Owner': 'Assignee', 'Description': 'Description', 'Tags': 'Labels'}) for row in df2.iterrows(): summ = str(df2.loc[row[0], 'Summary']) desc = str(df2.loc[row[0], 'Description']) #These have to be updated featureid = str(df2.loc[row[0], 'Feature ID'])# customfield_10007, type is label owner = str(df2.loc[row[0], 'Assignee']) # need to update usernames or have a lookup tags = str(df2.loc[row[0], 'Labels']) # Needs to return an array try: jira_options = {'server': jira_url} jira = JIRA(options=jira_options, basic_auth=(jira_user, jira_password)) log.info("Connecting to JIRA: %s" % jira_url) #customfield_10007=featureid, assignee=owner, description=desc, labels=tags, issue = jira.create_issue(project={'key': jira_project_key}, summary = summ, description = desc, issuetype = {'name': jira_issue_type}) print issue ,'was created.' #getissue = jira.issue('issue') issue.update(fields={"customfield_10007":featureid}) except JIRAError, e: log.error("Failed to connect to JIRA: %s" % e) print "Failed to connect to JIRA ",e return None outrows = len(df2) log.info(outrows, ' Features written to JIRA.') Output from above: text: data was not an array response headers = {'X-AUSERNAME': 'jira_user', 'X-AREQUESTID': '1248x4728x1', 'X-Content-Type-Options': 'nosniff', 'Content-Encoding': 'gzip', 'Transfer-Encoding': 'chunked', 'X-Seraph-LoginReason': 'OK', 'Vary': 'User-Agent', 'X-ASESSIONID': '1lpzagg', 'Connection': 'close', 'Cache-Control': 'no-cache, no-store, no-transform', 'Date': 'Tue, 11 Apr 2017 01:48:58 GMT', 'Content-Type': 'application/json;charset=UTF-8', 'X-ASEN': 'SEN-L9516098'} response text = {"errorMessages":[],"errors":{"customfield_10007":"data was not an array"}} Process finished with exit code 0
Not sure how to get the output into a list. I tried mylist = featureid.split() to get content into a list but that didn't work either.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.