You've already forked jenkins-lib
forked from jenkins/jenkins-lib
Шаг для анализа сонаром
This commit is contained in:
26
vars/sonar-scanner.groovy
Normal file
26
vars/sonar-scanner.groovy
Normal file
@@ -0,0 +1,26 @@
|
||||
import com.cloudbees.groovy.cps.NonCPS
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field def sonarCommand
|
||||
|
||||
def call(String rootFile = 'src/cf/Configuration.xml') {
|
||||
|
||||
String scannerHome = tool 'sonar-scanner'
|
||||
sonarCommand = "$scannerHome/bin/sonar-scanner -Dsonar.branch.name=$env.BRANCH_NAME"
|
||||
|
||||
def configurationText = readFile encoding: 'UTF-8', file: rootFile
|
||||
String configurationVersion = version(configurationText)
|
||||
if (configurationVersion) {
|
||||
sonarCommand += " -Dsonar.projectVersion=$configurationVersion"
|
||||
}
|
||||
|
||||
withSonarQubeEnv('qa.dev.pulsar.ru') {
|
||||
cmd sonarCommand
|
||||
}
|
||||
}
|
||||
|
||||
@NonCPS
|
||||
private static String version(String text) {
|
||||
def matcher = text =~ /<Version>(.*)<\/Version>/
|
||||
return matcher ? matcher.group(1) : ""
|
||||
}
|
Reference in New Issue
Block a user