I'm creating a Jenkins pipeline using Blue ocean.
Now I try to add a SonarQube analysis to the flow. But when I run the flow it says:
No steps This stage has no steps
The stage looks like:
stage('Analysis') {
steps {
script {
if (env.BRANCH_NAME == 'develop') {
withSonarQubeEnv('SonarQube Server') {
bat 'mvn sonar:sonar'
def qualitygate = waitForQualityGate()
if (qualitygate.status != "OK") {
error "Pipeline aborted due to quality gate coverage failure: ${qualitygate.status}"
}
}
}
}
}
}
The flow is running in the develop branch: I don't know why Jenkins says this error. can someone help me with this?
Changed my flow to use the when keyword:
stage('SonarQube analysis') {
when {
branch 'develop'
}
steps {
withSonarQubeEnv('SonarQube') {
bat 'mvn sonar:sonar'
}
}
}
stage("SonarQube Quality Gate") {
when {
branch 'develop'
}
steps {
timeout(time: 10, unit: 'MINUTES') {
script {
sleep 120
def qg = waitForQualityGate()
if (qg.status != 'OK') {
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}
}
}
}