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?
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'"
}