Home > Mobile >  Jenkins waitForQualityGate wrong id
Jenkins waitForQualityGate wrong id

Time:10-20

I'm trying to integrate Sonarqube in my Jenkins pipeline, all works fine untile gateway checks.

    stage('Sonar') {
        steps {
            withSonarQubeEnv(installationName: 'Sonarqube', credentialsId: 'sonar') {
            sh "$SCANNER_HOME/bin/sonar-scanner -D'sonar.projectKey=$JOB_NAME'"
            }
        }
    }
    stage("Quality Gate") {
        steps {
          timeout(time: 1, unit: 'HOURS') {
            waitForQualityGate abortPipeline: true
          }
        }
    }

withSonarQubeEnv reports an id, for example: AXyPGkHZtOM2BAFbSUcX . Using api/ce/task?id=AXyPGkHZtOM2BAFbSUcX I can see process status and analysisId(f.e. AXyPGkmqJtbgJ09MpQ6B) The point is that waitForQualityGate alway reads api/qualitygates/project_status?analysisId=AXyLfj5JlX0w7MRERt_e resulting in a 404. I'm on that from something like 5 h and can't get out. Someone has ideas?

CodePudding user response:

The stages look fine, the HTTP 404 issue is due SonarQube not understanding the projectKey by the looks of it, from above you have-D'sonar.projectKey=$JOB_NAME' . The command & variable are defined incorrectly, it should be -Dsonar.projectKey='$JOB_NAME'.

That way the SonarQube server will be able to send analysis back to the Jenkins webhook with the correct key

CodePudding user response:

I found the problem. I moved sonarcube temp files to another location. Those changes reflect on Jenkins too but plug-in can't handle that so it was looking for file before the temp-dir change.

  • Related