I am using Jenkins v2.69 with Pipeline plugin v2.5. My Sonarqube version is - v6.6 and gradle sonarqube version is - 2.6.1.
I am using sonar analysis with gradle in my Jenkins Pipeline.
Till date - We were having Sonarqube version - 5.6.6 in which there was support for "preview" mode (property "sonar.analysis.mode", "preview"), so we used to do the analysis in that mode in our pre-commit pipeline step and used to fail our build if it doesn't match the quality.
so does it mean this version of sonarqube does not support "preview" mode?
Though, i noticed if i try to do a sonar analysis ("publish" mode) with a user who don't have permissions to do then i get message as above which make sense here as user doesn't have permissions to do that.
But the error does mention about "preview" mode, so does that mean it is still there?
Error Snippet:
17:03:25 Execution failed for task ':sonarqube'.
17:03:25 > You're only authorized to execute a local (preview) SonarQube analysis without pushing the results to the SonarQube server. Please contact your SonarQube administrator.
17:03:25
So this is misleading me, could someone please clarify?
Also, if the preview mode has been take out, what is the way forward to do the equivalent in Jenkins pipeline.
Second problem is -
My Jenkins pipeline code snippet is -
Code Snippet -
stage('Static Analysis') {
withEnv(["PATH+GRADLE=${tool 'gradle-4-2-1'}/bin",
"PATH+JDK=${tool 'jdk-8u121'}/bin",
"JAVA_HOME=${tool 'jdk-8u121'}"]) {
timeout(time: 15, unit: 'MINUTES') {
withSonarQubeEnv('mobile-sbx-sonar') {
sh "gradle --info -Dsonar.analysis.mode=publish -Dsonar.login=test -Dsonar.password=myPassword -PsonarBranch=${SONAR_BRANCH} sonarqube"
}
}
}
}
stage("Quality Gate"){
timeout(time: 1, unit: 'HOURS') { // Just in case something goes wrong, pipeline will be killed after a timeout
def qg = waitForQualityGate() // Reuse taskId previously collected by withSonarQubeEnv
if (qg.status != 'OK') {
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}
}
So if i allow anonymous access in Sonarqube to execute analysis, everything works fine.
But if i turns that off, then my "Quality Gate" stage fails.
Basically, I am looking for a way to pass the credentials to waitForQualityGate().
(I don't want to specify the user details in Sonar plugin configuration in Jenkins as we manage that via ansible and then it will be in plain text?)