1
0

sonar-scanner -> sonarScanner

This commit is contained in:
Nikita Gryzlov
2020-03-25 17:34:44 +03:00
parent ab35b00476
commit 39acf5efb0

26
vars/sonarScanner.groovy Normal file
View 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) : ""
}