美文网首页编程语言
使用python统计jira bug数据

使用python统计jira bug数据

作者: 西西的博客 | 来源:发表于2018-08-01 20:55 被阅读34次

一、写在前面

公司每天早晨站立会时,都需要测试人员报告一下目前的bug情况,包括待办、测试中、完成的数量,以及各个开发端:ios、android、api....的情况。

于是测试人员每天早晨到公司后都需要做这样的事:统计一下到今天早晨为止,bug的情况。这样的事做一次还好,如果每天都做,真是一件费时的事......

如果能写一个程序,每天只需要运行一下程序,就能把想要的数据统计好,这样会不会更好些呢?

这次要说的是使用python统计jira上的bug数据

二、程序运行结果

程序运行后出现了我想要的统计结果,如下图所示。

简单介绍一下统计的内容。内容包括了项目的四个部分:ios(APP端)、android(APP端)、api(后端)、shuri(前端),其中30(0-0-15-15-0),表示ios端有30个bug待办,从左到右表示bug等级从Highest、High、Medium、Low、Lowest这五个等级对应的bug的数量

bug统计结果

三、jira包下载

使用以下命令安装jira包

pip install jira

四、JQL语句的使用

程序使用JQL对bug数据进行查询和统计

看到这里,各位不要慌额。我弄这个的时候原本以为需要把JQL的相关语法从头到尾的学习一遍呢,其实并不需要

jira中能将你的查询用JQL表示出来,见下图,在图中前面部分的查询条件中填写好你需要查询的条件,然后点击高级,就能将你的查询的语句转化为JQL语句

jira简单查询

下图是jira中高级查询的JQL语句,是不是很棒呀

jira高级查询

五、编写代码

给出程序源码

#coding=utf-8
from jira import JIRA

jira_server = 'http://jira.com'  #jira地址
jira_username = 'username' #用户名
jira_password = 'password' #密码

jira = JIRA(basic_auth=(jira_username, jira_password), options = {'server': jira_server})

#print(jira.user(jira.current_user()))#当前用户

#
done = jira.search_issues('project = "test" AND issuetype = 故障 AND status = Done  ',maxResults=100000)

testing = jira.search_issues('project = "test" AND issuetype = 故障 AND status = 测试中  ',maxResults=100000)

toDo = jira.search_issues('project = "test" AND issuetype = 故障 AND status = "To Do"  ',maxResults=100000)


#ios

ios_done = jira.search_issues('project = RRPK AND issuetype = 故障 AND status = Done AND text ~ "ios"  ',maxResults=100000)

ios_testing = jira.search_issues('project = RRPK AND issuetype = 故障 AND status = 测试中 AND text ~ "ios"  ',maxResults=100000)

ios_toDo = jira.search_issues('project = RRPK AND issuetype = 故障 AND status = "To Do" AND text ~ "ios" ',maxResults=100000)

ios_Highest = jira.search_issues('project = RRPK AND issuetype = 故障 AND status = "To Do" AND priority = Highest AND text ~ "ios" ',maxResults=100000)
ios_High = jira.search_issues('project = RRPK AND issuetype = 故障 AND status = "To Do" AND priority = High AND text ~ "ios" ',maxResults=100000)
ios_Medium = jira.search_issues('project = RRPK AND issuetype = 故障 AND status = "To Do" AND priority = Medium AND text ~ "ios" ',maxResults=100000)
ios_Low = jira.search_issues('project = RRPK AND issuetype = 故障 AND status = "To Do" AND priority = Low AND text ~ "ios" ',maxResults=100000)
ios_Lowest = jira.search_issues('project = RRPK AND issuetype = 故障 AND status = "To Do" AND priority = Lowest AND text ~ "ios" ',maxResults=100000)

#android

android_done = jira.search_issues('project = "test" AND issuetype = 故障 AND status = Done AND text ~ "android"  ',maxResults=100000)

android_testing = jira.search_issues('project = "test" AND issuetype = 故障 AND status = 测试中 AND text ~ "android"  ',maxResults=100000)

android_toDo = jira.search_issues('project = "test" AND issuetype = 故障 AND status = "To Do" AND text ~ "android"  ',maxResults=100000)

android_Highest = jira.search_issues('project = RRPK AND issuetype = 故障 AND status = "To Do" AND priority = Highest AND text ~ "android" ',maxResults=100000)
android_High = jira.search_issues('project = RRPK AND issuetype = 故障 AND status = "To Do" AND priority = High AND text ~ "android" ',maxResults=100000)
android_Medium = jira.search_issues('project = RRPK AND issuetype = 故障 AND status = "To Do" AND priority = Medium AND text ~ "android" ',maxResults=100000)
android_Low = jira.search_issues('project = RRPK AND issuetype = 故障 AND status = "To Do" AND priority = Low AND text ~ "android" ',maxResults=100000)
android_Lowest = jira.search_issues('project = RRPK AND issuetype = 故障 AND status = "To Do" AND priority = Lowest AND text ~ "android" ',maxResults=100000)

#api:

api_done = jira.search_issues('project = "test" AND issuetype = 故障 AND status = Done AND text ~ "api"   ',maxResults=100000)

api_testing = jira.search_issues('project = "test" AND issuetype = 故障 AND status = 测试中  AND text ~ "api" ',maxResults=100000)

api_toDo = jira.search_issues('project = "test" AND issuetype = 故障 AND status = "To Do" AND text ~ "api"  ',maxResults=100000)

api_Highest = jira.search_issues('project = RRPK AND issuetype = 故障 AND status = "To Do" AND priority = Highest AND text ~ "api" ',maxResults=100000)
api_High = jira.search_issues('project = RRPK AND issuetype = 故障 AND status = "To Do" AND priority = High AND text ~ "api" ',maxResults=100000)
api_Medium = jira.search_issues('project = RRPK AND issuetype = 故障 AND status = "To Do" AND priority = Medium AND text ~ "api" ',maxResults=100000)
api_Low = jira.search_issues('project = RRPK AND issuetype = 故障 AND status = "To Do" AND priority = Low AND text ~ "api" ',maxResults=100000)
api_Lowest = jira.search_issues('project = RRPK AND issuetype = 故障 AND status = "To Do" AND priority = Lowest AND text ~ "api" ',maxResults=100000)

#shuri

shuri_done = jira.search_issues('project = "test" AND issuetype = 故障 AND status = Done  AND text ~ "shuri" ',maxResults=100000)

shuri_testing = jira.search_issues('project = "test" AND issuetype = 故障 AND status = 测试中 AND text ~ "shuri"  ',maxResults=100000)

shuri_toDo = jira.search_issues('project = "test" AND issuetype = 故障 AND status = "To Do"  AND text ~ "shuri" ',maxResults=100000)

shuri_Highest = jira.search_issues('project = RRPK AND issuetype = 故障 AND status = "To Do" AND priority = Highest AND text ~ "shuri" ',maxResults=100000)
shuri_High = jira.search_issues('project = RRPK AND issuetype = 故障 AND status = "To Do" AND priority = High AND text ~ "shuri" ',maxResults=100000)
shuri_Medium = jira.search_issues('project = RRPK AND issuetype = 故障 AND status = "To Do" AND priority = Medium AND text ~ "shuri" ',maxResults=100000)
shuri_Low = jira.search_issues('project = RRPK AND issuetype = 故障 AND status = "To Do" AND priority = Low AND text ~ "shuri" ',maxResults=100000)
shuri_Lowest = jira.search_issues('project = RRPK AND issuetype = 故障 AND status = "To Do" AND priority = Lowest AND text ~ "shuri" ',maxResults=100000)



print ('\n\n        待办          测试中     已完成')
print ('总:'+'       '+str(len(toDo))+'          '+str(len(testing))+'       '+str(len(done)))
print ('ios:        '+str(len(ios_toDo))+'('+str(len(ios_Highest))+'-'+str(len(ios_High))+'-'+str(len(ios_Medium))+'-'+str(len(ios_Low))+'-'+str(len(ios_Lowest))+')        '+str(len(ios_testing))+'       '+str(len(ios_done)))
print ('android:    '+str(len(android_toDo))+'('+str(len(android_Highest))+'-'+str(len(android_High))+'-'+str(len(android_Medium))+'-'+str(len(android_Low))+'-'+str(len(android_Lowest))+')        '+str(len(android_testing))+'       '+str(len(android_done)))
print ('api:        '+str(len(api_toDo))+'('+str(len(api_Highest))+'-'+str(len(api_High))+'-'+str(len(api_Medium))+'-'+str(len(api_Low))+'-'+str(len(api_Lowest))+')        '+str(len(api_testing))+'       '+str(len(api_done)))
print ('shuri:      '+str(len(shuri_toDo))+'('+str(len(shuri_Highest))+'-'+str(len(shuri_High))+'-'+str(len(shuri_Medium))+'-'+str(len(shuri_Low))+'-'+str(len(shuri_Lowest))+')        '+str(len(shuri_testing))+'     '+str(len(shuri_done)))

六、写在最后

这个程序写的不是很好,运行速度也比较慢,总体上来说还可以,毕竟可以使用并且能达到我想要的需求

在这里只是为大家提供一个方向,分享一下我学习这块遇到的一些问题,希望对你有所帮助 ^ _ ^

相关文章

  • 使用python统计jira bug数据

    一、写在前面 公司每天早晨站立会时,都需要测试人员报告一下目前的bug情况,包括待办、测试中、完成的数量,以及各个...

  • 使用python统计jira数据

    1. 前提 首先JIRA就不多做介绍了,很多公司都在用它来管理版本、需求、缺陷等,我司也不例外,所有的测试申请都是...

  • 用Python统计JIRA数据

    本文结构: 用自己初步写的Python统计JIRA结构 针对代码的结构和语法,显示其优化后的代码 本文目的: 自己...

  • 大数据带你解读图书馆借阅情况

    统计方法 数据来自学校官网,使用python爬虫抓取数据,统计数据截至2017/4/9,使用excel及魔镜进行数...

  • Python操作Jira方法

    [TOC]Jira提供了完善的RESTful API,如果不想直接请求API接口可以使用Python的Jira库来...

  • jenkins自动发送jira项目不同状态bug数量

    在工作中有这样一种想法:bug统计在jira中,而为了及时的告知各位产品开发项目bug的解决数量,我要实现jenk...

  • JIRA-Dashboard复制引用仪表盘

    前言 在功能测试过程中,主要使用JIRA来进行bug管理,以及产出项目报告。 JIRA 疑问 如何更换筛选器结果呢...

  • git提交规范

    命名规范:分支:feature[jira号] bugFix: bug[jira号] tag:v[版本号] 流程

  • git提交规范

    命名规范: 分支:feature[jira号] bugFix: bug[jira号] tag:v[版本号] 流程

  • jira的使用小结(未完)

    当前工作中bug记录在jira中,jira放在了confluence中,新建bug时,没注意类型,结果新建的是测试...

网友评论

    本文标题:使用python统计jira bug数据

    本文链接:https://www.haomeiwen.com/subject/sdtdvftx.html