Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To enforce the Quality Gate in Jenkins you can use the SonarQube Scanner plugin. To configure the BMA you can follow the provided example configuration of this plugin. The only way the BMA configuration deviates from this example is in the way it triggers the analysis.

Instead of using the "sh '"mvn clean package sonar:sonar'"" command, use the "java -jar  <location on disk>\bma-sonar-scanner.jar" command to trigger the analysis.

It may occur that after the analysis stage, SonarQube needs some time to process the results while Jenkins already proceeds to the Quality Gate stage. It could therefore be useful to add a wait step.

Example pipeline:

Code Block
pipeline {
        agent none
        stages {
          stage("BMA SonarQube analysis") {
            agent any
            steps {
              withSonarQubeEnv('My SonarQube Server') {
                java -Dspring.config.location=file:C:\bma\application.properties -jar C:\bma\bma-sonar-scanner.jar
              }
            }
          }
          stage("Quality Gate") {
            steps {
              timeout(time: 1, unit: 'HOURS') {
                waitForQualityGate abortPipeline: true
              }
            }
          }
        }
      }

...