在构建多分支管道时,我使用SonarQube插件将我的每个项目发送到SonarQube,如下所示:
pipeline {
agent any
options {
buildDiscarder(logRotator(numToKeepStr:'20'))
timeout(time: 30, unit: 'MINUTES')
}
tools {
maven 'Maven 3.3.9'
jdk 'JDK 1.8'
}
stages {
stage('Checkout') {
steps {
echo 'Checking out..'
checkout scm
echo "My branch is: ${env.BRANCH_NAME}"
}
}
stage('Build') {
steps {
echo 'Building..'
bat 'mvn clean verify -P!local'
}
}
stage('SonarQube analysis'){
steps{
echo 'Analysing...'
withSonarQubeEnv('SonarQube') {
bat 'mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar'
}
}
}
}
}
它工作正常,但我需要做的一件事是将SonarQube中的项目名称更改为projectName/builtBranch,而不仅仅是项目名称。有没有办法使用管道来做到这一点?
这似乎不是 Jenkins 的问题;相反,您应该能够设置各种sonar.*
属性(例如 sonar.projectName
或sonar.branch
(运行时运行Maven插件。
该文档似乎有一个完整的列表:https://docs.sonarqube.org/display/SONAR/Analysis+Parameters