Have a very interesting problem here. Using Jenkins (2.150), SonarQube Scanner plugin (2.9), and running the Jenkins executors via Kubernetes plugin 1.15.2.
If you run the following job description you will notice that the quotes are stripped from the environment variable SONARQUBE_SCANNER_PARAMS which gives you an error:
{ sonar.host.url : https://sonarqube-url.com, sonar.login : ******}
^
SyntaxError: Unexpected token s in JSON at position 2
We are calling sonar with “npm run sonar”.
Job description to recreate:
#!groovy
node {
container('jenkins-slave') {
sh 'env'
withSonarQubeEnv('sonarqube'){
sh 'env'
withDockerContainer(image: 'ubuntu') {
sh 'env'
}
}
}
}
Notice that the 1st env doesn’t have the environment variable, the 2nd does (with quotes that would work), and the 3rd strips the quotes (like the example above). I’m expecting the following to work: { “sonar.host.url” : “https://sonarqube-url.com”, “sonar.login” : “******”}
Things I’ve done include trying to pass in the url and login but it appears that the login (an authentication token that works for other projects not running in docker) turns into the literal **** instead of just not showing it on the console output.
Command used when doing it that way:
env -u SONARQUBE_SCANNER_PARAMS npm run sonar --verbose sonar.host.url=https://sonarqube-site.com --sonar.login=******
I think it does the literal of **** because I’ve tested calling: curl -v -u ******: https://sonarqube-site.com/api/user_tokens/search doesn’t return anything after “withSonarQubeEnv” is called but works before.
Any thoughts on how to pass the environment variable with quotes? It seems like I can’t even re-export as the **** doesn’t let me export or print without it being obfuscated.
Thanks in advance for helping out.