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

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

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

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

 

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

图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数的链接

 

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

图2

 

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

图3

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

相关文章:

  • 2021-07-16
  • 2021-08-19
  • 2022-12-23
  • 2021-06-29
  • 2021-08-16
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-24
  • 2021-08-02
  • 2021-12-03
  • 2022-12-23
  • 2021-09-17
  • 2022-12-23
  • 2021-10-01
相关资源
相似解决方案