1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00

sonarExecuteScan: avoid working directory being deleted before scan detection ends (#882)

This commit is contained in:
Sven Merk 2019-10-28 13:01:51 +01:00 committed by Christopher Fenner
parent bb59e68df3
commit 0f3436d1a5

View File

@ -120,21 +120,22 @@ void call(Map parameters = [:]) {
configuration.options = [].plus(configuration.options)
def worker = { config ->
withSonarQubeEnv(config.instance) {
try{
loadSonarScanner(config)
try {
withSonarQubeEnv(config.instance) {
loadCertificates(config)
loadSonarScanner(config)
if(config.organization) config.options.add("sonar.organization=${config.organization}")
if(config.projectVersion) config.options.add("sonar.projectVersion=${config.projectVersion}")
// prefix options
config.options = config.options.collect { it.startsWith('-D') ? it : "-D${it}" }
loadCertificates(config)
sh "PATH=\$PATH:${env.WORKSPACE}/.sonar-scanner/bin sonar-scanner ${config.options.join(' ')}"
}finally{
sh 'rm -rf .sonar-scanner .certificates .scannerwork'
if(config.organization) config.options.add("sonar.organization=${config.organization}")
if(config.projectVersion) config.options.add("sonar.projectVersion=${config.projectVersion}")
// prefix options
config.options = config.options.collect { it.startsWith('-D') ? it : "-D${it}" }
sh "PATH=\$PATH:${env.WORKSPACE}/.sonar-scanner/bin sonar-scanner ${config.options.join(' ')}"
}
} finally {
sh 'rm -rf .sonar-scanner .certificates .scannerwork'
}
}