pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'mvn install clean install -Dsonar.login=test -Dsonar.password=test -Dsonar.host.url=http://myserver sonar:sonar '
}
}
stage('Quality Gate') {
steps {
sh 'echo "Sonar Analysis"'
waitForQualityGate()
}
}
---------
stage('Quality Gate') {
steps {
sh 'echo "Sonar Analysis"'
withSonarQubeEnv('http://myserver')
waitForQualityGate()
}
}
-----------------
stage('Quality Gate') {
steps {
sh 'echo "Sonar Analysis"'
withSonarQubeEnv('http:myserver')
def qualitygate = waitForQualityGate()
if (qualitygate.status != "OK") {
error "Pipeline aborted due to quality gate coverage failure: ${qualitygate.status}"
}
}
------------
pipeline {
agent any
environment {
withSonarQubeEnv = 'http://myserver/'
}
stages {
stage('Build') {
steps {
sh 'mvn install -Dsonar.login=test -Dsonar.password=test -Dsonar.host.url=http:myserver/ sonar:sonar '
}
}
stage('Quality Gate') {
steps {
sh 'echo "Sonar Analysis"'
waitForQualityGate()
}
}
------------