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

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

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

1、前期思路,操作jira查询,抓取接口,通过解析接口获取bug数,最后发现不可行,因为jira没有单独的接口,数据库不对外暴露

2、最后通过ui自动化+http+钉钉api实现

 

图1

3、pom.xml中引入:

  <dependency>

            <groupId>org.apache.httpcomponents</groupId>

            <artifactId>httpclient</artifactId>

            <version>4.3.1</version>

        </dependency>

        <dependency>

            <groupId>org.apache.httpcomponents</groupId>

            <artifactId>httpcore</artifactId>

            <version>4.3.3</version>

        </dependency>

</dependencies>

4、java发送钉钉通知的方法抽出公用的数据

title:标题    content:消息体    url:点击跳转链接    token:对应的钉钉token

private void testReport(String title ,String content,String url,String token) {

        HttpClient httpclient = HttpClients.createDefault();

        HttpPost httppost = new HttpPost(token);

        httppost.addHeader("Content-Type", "application/json; charset=utf-8");

 

        String test="{\"msgtype\": \"link\",\"link\": {\"text\":\""+content+"\",\"title\": \""+title+"\", \"picUrl\": \"\", \"messageUrl\":\""+url+"\"}}";

        System.out.println(test);

        StringEntity se = new StringEntity(test, "utf-8");

        httppost.setEntity(se);

        HttpResponse response;

try {

response = httpclient.execute(httppost);

if (response.getStatusLine().getStatusCode()== HttpStatus.SC_OK){

            String result= EntityUtils.toString(response.getEntity(), "utf-8");

            System.out.println(result);

        }

} catch (ClientProtocolException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

5、webdriver去获取jira页面的元素,优先判断登录状态,其次通过筛选拿到每种bug数的链接

 

图2

 

图3

如果大家对于学习Python有任何问题,学习方法,学习路线,如何学习有效率的问题,可以随时来咨询我,或者缺少系统学习资料的,我做这行年头比较久,自认为还是比较有经验的,可以帮助大家提出建设性建议,这是我的Python交流qun:785128166,有任何问题可以随时来咨询我。
 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值