jira python customfield

Pau*_*son 10 python jira custom-fields

如何在jira-python中确定自定义字段的名称?

当我检索到问题时,我的自定义字段显示为customfield_xxx

我的屏幕上的名称是"项目","名称","截止日期"等.在每个字段中放置一个值,然后在重新阅读问题时查看它出现的位置.

那就是我可以在我的一个字段中加上'a',然后阅读问题,并发现customfield_10801(或其他)的值为'a'.但有没有一种通用的方法来查找,例如,如果我的自定义字段是'截止日期',customfield_xxx是否会映射到它?

或者,在JIRA GUI中,我将如何查找这些customfield#.

Luk*_*lar 17

从GUI中,您可以在html代码或url中看到自定义字段ID:

  • 在管理页面上,您感兴趣的自定义字段的行上列出了所有自定义字段,右键单击齿轮,然后单击/将鼠标悬停在"配置"上.您应该在URL中看到自定义字段ID.

另一种方法是通过REST API:

  • {JIRA碱基URL} /休息/ API/2 /场
  • 这是一个GET请求,所以只需将该URL放入浏览器即可.

更新:

根据评论,可以这样做:

# Fetch all fields
allfields=jira.fields()
# Make a map from field name -> field id
nameMap = {field['name']:field['id'] for field in allfields}
# Fetch an issue
issue = jira.issue('ABC-1')
# You can now look up custom fields by name using the map
getattr(issue.fields, nameMap[custom_name])
Run Code Online (Sandbox Code Playgroud)

  • allfields = jira.fields(); nameMap = {field ['name']:field ['id']},用于allfields中的字段} (2认同)