jenkinssonarqubejenkins-pluginssonarqube-scan

Jenkins : How to get sonar environment variables


How to get sonar environment variables like sonar host, sonar project key or sonar workspace in order to use them in email with Jenkins plugin: Editable Email Notification.

any help or idea ?


Solution

  • you can use the withSonarQubeEnv() plugin function to pull the values. You have to configure Jenkins with the Sonar variables you want it to use. You can find more info about that at the link below. Unfortunately, I can't seem to find documentation from Sonarqube what variables are being provided. You might want to run something like sh "env" within the withSonarQubeEnv stanza to get an idea.

    https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Jenkins#AnalyzingwithSonarQubeScannerforJenkins-AnalyzinginaJenkinspipeline