当前位置: 首页 > 知识库问答 >
问题:

使用Python REST API在JIRA中创建问题和自定义字段

陶温书
2023-03-14

我正在使用JIRA Python模块,它是REST API的一个扩展,用于自动化JIRA中删除和创建问题的过程。我试图在JIRA中使用python脚本中的“for”循环创建问题,该脚本使用从另一个数据库收集的导入数据。我需要在创建问题时格式化字段,以便我拥有的数据可以与JIRA中的相应字段正确对齐。下面是我的Python代码,用于创建问题并将数据存储到JIRA中,JIRA存储在自定义变量中:

df包含13列数据,我想通过创建新问题将其输入JIRA。每列代表JIRA中一个问题的不同字段。在JIRA中创建的每一个新问题都应该从每个专栏获得信息:

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

它给出了错误:

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 html" target="_blank">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."}"

下面是一些在JIRA中显示的在注释字段中创建的每个问题的示例数据:

问题1:
0 NaN
1发现增量将泄漏接收到的数据包
2每次断开连接时,增量都会重置
3 NaN
4应该在CP到达l时记录
5通过BioMed菜单升级IDS后
6通过BioMed菜单升级IDS后
7通过BioMed菜单升级IDS后
8增加了熔合堆大小和SCC1初始化
9马特交付后,使用build 142重新检查
10使用WPA2时,有EAPOL键echange go
11使用WPA2时,有EAPOL键echange go<12南
13南
14南。。。

我只希望每一期都有自己的字符串值,而不是索引号或NaN显示如下:


问题1:
问题2:发现Delta会泄漏数据包接收...
问题3:每次断开连接,Delta都会重置...

共有1个答案

洪昱
2023-03-14

代码的一个主要缺陷是在循环数据之前就分配了数据。

df = pd.read_csv('C:\\Python27\\scripts\\export.csv')

for row in df:
    cqid = row['ClearQuest ID']
    summary = row.Summary
    jira.create_issue(...)

你很可能需要做这样的事情。

for row in df.values:
    cqid , summary , value3, value4, value5 = row
 类似资料:
  • 我想知道有没有一种方法可以在创建问题时自动创建子任务。 例如,我创建了一个自定义的标准问题类型XXX,以及子任务问题类型YYY和ZZZ。当我创建一个XXX类型的问题时,将自动创建两个子任务,分别具有YYY和ZZZ类型的问题。

  • 问题内容: 如何使用其余API在jira中创建问题。我已经尝试过使用curl的示例。但是我需要使用java和rest api在eclipse中创建缺陷。 问题答案: 您想将JIRA集成到Eclipse中吗? 参见:https : //confluence.atlassian.com/display/IDEPLUGIN/Working+with+JIRA+Issues+in+Eclipse 您想要自

  • 我正在创建一个自定义标记库,并希望在我的一个组件中使用它。我已经创建了一个包,其中包括扩展TagSupport类的标记hello类,我创建了标记。我的资源文件夹下的tld文件 在我的pom中。xml,我使用了资源标记来包含我的。生成的jar文件中的tld文件。 这是我的java类和tld文件 标记类别:- 我还成功地在felix控制台中安装了该捆绑包,没有出现任何错误。然后,我在jsp中编写了自定

  • 我想通过s在JIRA中创建一个问题。 我的问题是,如何发送(base64)图像并请求新的JIRA? 是否有任何参数,如其他字段(摘要,描述)或其他方式来发送编码图像? 我对jQuery函数的请求如下: 发送Encoded(base64格式的图像)和此请求是否可行?

  • 在创建新的字段类型之前,请考虑其他自定义字段的方法是否适合您的需求。 如果您的应用程序需要存储新的值类型,或者希望为现有的值类型创建新的UI,则可能需要创建一个新的字段类型。 要创建一个新字段,请执行以下操作: 实现一个构造函数 注册一个JSON密钥并实现fromJson 处理块上UI和事件侦听器的初始化 处理事件侦听器(已为您进行了UI处理) 实现值处理 添加字段值的文本表示形式,以实现可访问性

  • 通过“自定义字段”方法创建数据后,数据里没有任何记录,需要到地图编辑模块添加数据。新建数据时,请注意选择到数据类型(点线面),创建完成后不可以修改。 选择通过自定义字段创建,需要手动输入属性列,并选择好属性列的类型,如文本/数值等。其中数值列可以用于统计。