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

refactor(sonar): provide trust store via JVM parameter (#1270)

* provide trust store via JVM parameter

* adjust test cases

* Update vars/sonarExecuteScan.groovy

* Update vars/sonarExecuteScan.groovy

* Update sonarExecuteScan.groovy
This commit is contained in:
Christopher Fenner 2020-03-16 10:34:07 +01:00 committed by GitHub
parent db8cb2bf62
commit a970507619
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 9 deletions

View File

@ -56,6 +56,9 @@ class SonarExecuteScanTest extends BasePiperTest {
binding.setProperty(l[0].variable, null)
}
})
helper.registerAllowedMethod('withEnv', [List.class, Closure.class], { List envVars, Closure body ->
body()
})
nullScript.commonPipelineEnvironment.setArtifactVersion('1.2.3-20180101')
}

View File

@ -124,19 +124,21 @@ void call(Map parameters = [:]) {
def worker = { config ->
try {
withSonarQubeEnv(config.instance) {
List envVars = []
loadSonarScanner(config)
loadSonarScanner(config)
if(fileExists('.certificates/cacerts')){
sh 'mv .certificates/cacerts .sonar-scanner/jre/lib/security/cacerts'
}
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}" }
if(fileExists('.certificates/cacerts')){
envVars = envVars.plus("SONAR_SCANNER_OPTS=-Djavax.net.ssl.trustStore=${env.WORKSPACE}/.certificates/cacerts")
}
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}" }
withEnv(envVars){
sh "PATH=\$PATH:'${env.WORKSPACE}/.sonar-scanner/bin' sonar-scanner ${config.options.join(' ')}"
}
}
} finally {
sh 'rm -rf .sonar-scanner .certificates .scannerwork'