git branch合并/删除时自动删除Sonarqube分支项目 [英] Automatically remove Sonarqube branch projects when git branch merged / removed

查看:347
本文介绍了git branch合并/删除时自动删除Sonarqube分支项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们目前有一个使用Multibranch Workflow plugin的詹金斯管道.每个git分支执行一个声纳分析,使用sonar.branch属性创建一个声纳项目.这非常有用,因为在合并每个分支之前都会对其进行分析,当一个分支与master合并并在GIT上消失时,该问题就会出现,该项目将继续在sonarqube上进行,并且需要手动删除. 有没有办法自动做到这一点?或其他任何推荐?

We currently have a jenkins pipeline using Multibranch Workflow plugin. Each git branch execute a sonarqube analysis creating a sonarqube project using the sonar.branch property. This is very useful because each branch is being analyzed before merge it, the problem appear when a branch is merged with master and disappear on GIT, the project continues on sonarqube and need to be deleted manually. Is There a way to do it automatically? or any other recomendation?

推荐答案

您可以定义以下方法来执行此工作,然后根据需要或在某些事件(例如git branch merged/)上调用该方法删除,等等.

You can define a method as below, to do the job and then call the method whenever you need according to your need or on some event like git branch merged/removed, etc.

def deleteSonarProject() {
    def sonarToken = "-your admin credential token generate it from sonarServer-"
    def url = "http://yourBaseURL:portNumber/api/projects/delete"
    sh "curl -u ${sonarToken}: ${url} -d 'project=projectKey'"
}

这篇关于git branch合并/删除时自动删除Sonarqube分支项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆