- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试正确解析 JIRA webhook 评论部分。现在,以下代码适用于第一条评论:
data = request.json
jira_comment = data['issue']['fields']['comment']['comments'][0].get('body')
但是,每次触发新的 webhook 时,例如添加新评论,我只能收到 JSON 消息中的第一个评论。如果我能以某种方式识别来自另一个人的每条评论,或者只解析该问题的最后一条评论。最好的方法是什么,或者甚至可能,因为 JIRA webhook JSON 看起来已损坏(多个“body”键)。
请参阅下面的 JSON 数据,为了使其更清晰,请使用此 http://jsbeautifier.org/ :
{
"timestamp": 1443024903340,
"webhookEvent": "jira:issue_updated",
"user": {
"self": "http://192.168.10.58:8080/rest/api/2/user?username=jhdoe",
"name": "jhdoe",
"key": "jhdoe",
"emailAddress": "john.doe@corp.com",
"avatarUrls": {
"48x48": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=48",
"24x24": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=24",
"16x16": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=16",
"32x32": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=32"
},
"displayName": "John Doe",
"active": true,
"timeZone": "Europe/Berlin"
},
"issue": {
"id": "10300",
"self": "http://192.168.10.58:8080/rest/api/2/issue/10300",
"key": "DEMO-6",
"fields": {
"issuetype": {
"self": "http://192.168.10.58:8080/rest/api/2/issuetype/3",
"id": "3",
"description": "A task that needs to be done.",
"iconUrl": "http://192.168.10.58:8080/images/icons/issuetypes/task.png",
"name": "Task",
"subtask": false
},
"components": [],
"timespent": null,
"timeoriginalestimate": null,
"description": "Hey",
"project": {
"self": "http://192.168.10.58:8080/rest/api/2/project/10000",
"id": "10000",
"key": "DEMO",
"name": "DEMO",
"avatarUrls": {
"48x48": "http://192.168.10.58:8080/secure/projectavatar?avatarId=10011",
"24x24": "http://192.168.10.58:8080/secure/projectavatar?size=small&avatarId=10011",
"16x16": "http://192.168.10.58:8080/secure/projectavatar?size=xsmall&avatarId=10011",
"32x32": "http://192.168.10.58:8080/secure/projectavatar?size=medium&avatarId=10011"
}
},
"fixVersions": [],
"aggregatetimespent": null,
"resolution": null,
"timetracking": {},
"customfield_10006": null,
"attachment": [],
"customfield_10009": "0|i0000f:",
"aggregatetimeestimate": null,
"resolutiondate": null,
"workratio": -1,
"summary": "Comment test",
"lastViewed": "2015-09-23T19:14:11.979+0300",
"watches": {
"self": "http://192.168.10.58:8080/rest/api/2/issue/DEMO-6/watchers",
"watchCount": 1,
"isWatching": true
},
"creator": {
"self": "http://192.168.10.58:8080/rest/api/2/user?username=jhdoe",
"name": "jhdoe",
"key": "jhdoe",
"emailAddress": "john.doe@corp.com",
"avatarUrls": {
"48x48": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=48",
"24x24": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=24",
"16x16": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=16",
"32x32": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=32"
},
"displayName": "John Doe",
"active": true,
"timeZone": "Europe/Berlin"
},
"subtasks": [],
"created": "2015-09-21T17:39:14.518+0300",
"reporter": {
"self": "http://192.168.10.58:8080/rest/api/2/user?username=jhdoe",
"name": "jhdoe",
"key": "jhdoe",
"emailAddress": "john.doe@corp.com",
"avatarUrls": {
"48x48": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=48",
"24x24": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=24",
"16x16": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=16",
"32x32": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=32"
},
"displayName": "John Doe",
"active": true,
"timeZone": "Europe/Berlin"
},
"customfield_10000": null,
"aggregateprogress": {
"progress": 0,
"total": 0
},
"priority": {
"self": "http://192.168.10.58:8080/rest/api/2/priority/2",
"iconUrl": "http://192.168.10.58:8080/images/icons/priorities/high.png",
"name": "High",
"id": "2"
},
"customfield_10001": null,
"customfield_10100": "1234",
"customfield_10200": null,
"labels": [],
"customfield_10004": null,
"environment": null,
"timeestimate": null,
"aggregatetimeoriginalestimate": null,
"versions": [],
"duedate": null,
"progress": {
"progress": 0,
"total": 0
},
"comment": {
"startAt": 0,
"maxResults": 3,
"total": 3,
"comments": [{
"self": "http://192.168.10.58:8080/rest/api/2/issue/10300/comment/10600",
"id": "10600",
"author": {
"self": "http://192.168.10.58:8080/rest/api/2/user?username=jhdoe",
"name": "jhdoe",
"key": "jhdoe",
"emailAddress": "john.doe@corp.com",
"avatarUrls": {
"48x48": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=48",
"24x24": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=24",
"16x16": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=16",
"32x32": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=32"
},
"displayName": "John Doe",
"active": true,
"timeZone": "Europe/Berlin"
},
"body": "Comment 1",
"updateAuthor": {
"self": "http://192.168.10.58:8080/rest/api/2/user?username=jhdoe",
"name": "jhdoe",
"key": "jhdoe",
"emailAddress": "john.doe@corp.com",
"avatarUrls": {
"48x48": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=48",
"24x24": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=24",
"16x16": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=16",
"32x32": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=32"
},
"displayName": "John Doe",
"active": true,
"timeZone": "Europe/Berlin"
},
"created": "2015-09-23T19:05:26.593+0300",
"updated": "2015-09-23T19:08:07.010+0300"
}, {
"self": "http://192.168.10.58:8080/rest/api/2/issue/10300/comment/10601",
"id": "10601",
"author": {
"self": "http://192.168.10.58:8080/rest/api/2/user?username=jhdoe",
"name": "jhdoe",
"key": "jhdoe",
"emailAddress": "john.doe@corp.com",
"avatarUrls": {
"48x48": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=48",
"24x24": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=24",
"16x16": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=16",
"32x32": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=32"
},
"displayName": "John Doe",
"active": true,
"timeZone": "Europe/Berlin"
},
"body": "Comment 2",
"updateAuthor": {
"self": "http://192.168.10.58:8080/rest/api/2/user?username=jhdoe",
"name": "jhdoe",
"key": "jhdoe",
"emailAddress": "john.doe@corp.com",
"avatarUrls": {
"48x48": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=48",
"24x24": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=24",
"16x16": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=16",
"32x32": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=32"
},
"displayName": "John Doe",
"active": true,
"timeZone": "Europe/Berlin"
},
"created": "2015-09-23T19:08:13.644+0300",
"updated": "2015-09-23T19:08:13.644+0300"
}, {
"self": "http://192.168.10.58:8080/rest/api/2/issue/10300/comment/10606",
"id": "10606",
"author": {
"self": "http://192.168.10.58:8080/rest/api/2/user?username=jhdoe",
"name": "jhdoe",
"key": "jhdoe",
"emailAddress": "john.doe@corp.com",
"avatarUrls": {
"48x48": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=48",
"24x24": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=24",
"16x16": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=16",
"32x32": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=32"
},
"displayName": "John Doe",
"active": true,
"timeZone": "Europe/Berlin"
},
"body": "Comment 3",
"updateAuthor": {
"self": "http://192.168.10.58:8080/rest/api/2/user?username=jhdoe",
"name": "jhdoe",
"key": "jhdoe",
"emailAddress": "john.doe@corp.com",
"avatarUrls": {
"48x48": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=48",
"24x24": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=24",
"16x16": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=16",
"32x32": "http://www.gravatar.com/avatar/f94b6b6c15d155f4d4b3b2c05509ab0a?d=mm&s=32"
},
"displayName": "John Doe",
"active": true,
"timeZone": "Europe/Berlin"
},
"created": "2015-09-23T19:13:24.836+0300",
"updated": "2015-09-23T19:14:04.464+0300"
}]
},
"issuelinks": [],
"votes": {
"self": "http://192.168.10.58:8080/rest/api/2/issue/DEMO-6/votes",
"votes": 0,
"hasVoted": false
},
"worklog": {
"startAt": 0,
"maxResults": 20,
"total": 0,
"worklogs": []
},
"assignee": null,
"updated": "2015-09-23T19:15:03.338+0300",
"status": {
"self": "http://192.168.10.58:8080/rest/api/2/status/10000",
"description": "",
"iconUrl": "http://192.168.10.58:8080/images/icons/subtask.gif",
"name": "To Do",
"id": "10000",
"statusCategory": {
"self": "http://192.168.10.58:8080/rest/api/2/statuscategory/2",
"id": 2,
"key": "new",
"colorName": "blue-gray",
"name": "To Do"
}
}
}
},
"changelog": {
"id": "10611",
"items": [{
"field": "Custom ID",
"fieldtype": "custom",
"from": null,
"fromString": null,
"to": null,
"toString": "1234"
}]
}
}
最佳答案
json 中的注释部分是一个字典列表,因此您始终可以获取列表中的最后一个,然后调用 .get('body')
jira_comment = data['issue']['fields']['comment']['comments'][-1].get('body')
这是有效的,因为在Python中,数组索引中的负数被视为在数组中向后移动。所以 -1 给出数组中的最后一项。
当根本没有注释时,你的代码可以工作吗?如果它不考虑检查注释数组的长度是否大于 0,或者只是将其包装在 try except block 中。
关于python - 解析 JIRA webhook 注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32745086/
如何在 jira 中查看用户每周完成/正在进行的任务? 提前致谢。 最佳答案 您的问题不是很清楚,完成/进行中 是什么意思?问题的状态?并说我如何查看您到底是什么意思?从吉拉看到他们?发送每周邮件?
我正在使用树莓派墙板在壁挂式屏幕上显示项目 jira 状态。为了使树莓派作为墙板工作,我遵循了 http://blogs.wcode.org/2013/09/howto-boot-your-raspb
当我将 jira 问题的状态更改为其他人应该处理它时,我是否应该更改 jira 问题中的受让人? 什么是常用方法? (请提供您想法的可靠来源) 最佳答案 这取决于您想要实现的目标。如果您使用 JIRA
我想知道我对用户故事的估计有多准确。 我在 Jira + Greenhopper 中记录了我的时间,并查看了时间 tracking reports但我不确定如何按个人用户过滤故事 最佳答案 我通过创建
很抱歉,如果SO不是最好的地方,但是我在JIRA中启用了时间跟踪功能,并且希望能够为给定日期范围内的每个用户生成时间报告。我唯一的时间跟踪报告选项非常有限,并且没有执行我想要的操作,是否可以通过标准功
我需要过滤在特定日期之后进入RTT状态的票证。这些票证将立即解决,但是我需要查看所有在日期后进入该票证的票证,无论其当前状态如何。 最佳答案 例如,查找在Open之后其状态从Closed变为2012/
在JIRA中,如何在所有项目中查找与用户相关的所有问题。 简单的查询搜索仅产生全文结果。即,仅在提及该名称的问题上,而不是在名称已分配,已报告,已抄送等情况下出现的问题。 我的目的是在这里查找与我相关
安装 Sonar JIRA plugin 后并重新启动 Sonar 服务器,我使用 Sonar Ant 任务中配置的以下属性运行分析: sonar.jira.url(未使用 HTTPS) sonar.
我错误地将问题从“未开始”移至“已完成”。有办法把问题移回来吗? 我宁愿让它“进行中”。 最佳答案 答案是肯定的,但您可能需要自定义工作流程以添加从“完成”状态到其他状态的转换。确保使用发布功能清除解
JIRA 在哪里保存与票证相关的附件?我只想备份 JIRA 站点上的屏幕截图图像和文档。它是否将其保存在 MySQL BLOB 列类型中? 最佳答案 根据JRA-23758 (现在是 JRA-1987
鉴于 JIRA 中的一个问题有多个评论,是否有一种简单的方法可以从一个评论链接到另一个评论? 我可以使用永久链接,但这是一个又长又难看的 URL。我还可以链接到例如http://jira.exampl
安装 Sonar JIRA plugin 后并重新启动 Sonar 服务器,我使用 Sonar Ant 任务中配置的以下属性运行分析: sonar.jira.url(未使用 HTTPS) sonar.
我有一个独立的 JIRA 实例在我的服务器上运行。我使用 atlas-mvn 命令构建了一个 jira 插件,这创建了一个 jar 文件。 通常的过程是登录到独立的 JIRA UI 并从 UPM 进行
有没有办法使用 python JIRA 库在 JIRA 中获取冲刺的开始和结束日期?我可以得到 jira.client.ResultList使用 jira.sprints(jira.boards()[
我们有一些学员,我们想给他们一些 JIRA 的介绍性任务。 我们使用的是 JIRA 4.4 版。 在 JIRA 中实现以下目标的最少侵入方式(如果可能,避免创建全局组或权限)是什么: 限制学员用户帐户
我是 JIRA 插件开发的新手,所以我的问题可能听起来太简单了,但请耐心等待并仔细阅读,因为我已经尝试了很多东西,在互联网上找到,但都没有奏效。这就是为什么我在这里问它,作为我最后的希望。 我想用 J
我已经为 Jira 7 开发了 Jira Server 附加组件/插件,现在需要将其安装到 Jira 的云实例中。但是在我的插件的市场页面上它说: This hosting is not availa
我使用这个请求创建了一个 Jira 搜索过滤器: POST /rest/api/2/filter 这工作得很好。现在在我创建过滤器后,我想自动订阅它。 有没有办法用 REST API 做到这一点?或者
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 3 年前。
要求人们给我分配 jira 任务以实现一些问题或修复错误,当我完成任务后,我将任务分配给一些测试人员。 现在我想知道在当前项目/版本中分配给我的任务是检查文档。任何想法如何做到这一点? jira 中的
我是一名优秀的程序员,十分优秀!