You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用Python调用JIRA REST API按更新时间排序获取50个工单

修改JIRA查询为按更新时间排序获取工单列表

你只需要在JQL查询语句中添加排序规则,指定按更新时间倒序排列即可,默认返回的结果数量就是50条,无需额外调整。

修改后的代码如下:

jiraOptions = {'server': "https://xxx.atlassian.net"}
jira = JIRA(options=jiraOptions, basic_auth=(jira_workspace_email, jira_api_token))

# 在JQL中添加ORDER BY updated DESC,按更新时间倒序排序
for singleIssue in jira.search_issues(jql_str=f"project = GEN ORDER BY updated DESC"):
    key = singleIssue.key
    raw_fields_json = singleIssue.raw['fields']
    created = raw_fields_json['created']
    updated = raw_fields_json['updated']

说明

  • ORDER BY updated DESC:指定按工单的updated字段(更新时间)降序排列,最新更新的工单会排在结果最前面
  • 如果需要按更新时间升序(最早更新的在前),把DESC替换为ASC即可

内容的提问来源于stack exchange,提问作者Europa

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.06 06:20:41