SonarQube Scanner for Jenkins

Hi,

In the Scripted path, I could do something like this:

qualitygate = waitForQualityGate()
if (qualitygate.status != "OK") {
    currentBuild.result = "FAILURE"
    slackSend (channel: mychannel', color: '#F01717', message: "*$JOB_NAME*, <$BUILD_URL|Build #$BUILD_NUMBER>: '$STAGE_NAME' stage failed.")
}

In Declarative, the documentation suggests the following:

waitForQualityGate abortPipeline: true

In the Declarative path, how would I then notify to Slack in case of failure (not via a POST section, but inline)?

Also, would be nice to have a changelog for the Jenkins plug-in releases.

Hi,

For release notes, feel free to dig around in Jira: https://jira.sonarsource.com/browse/SONARJNKNS/?selectedTab=com.atlassian.jira.jira-projects-plugin:versions-panel.

Ann

Idan,

Admittedly I’m not very well-versed in Jenkins, but after combing through some docs

If the result of a failed quality gate is that the pipeline gets a status of ‘aborted’, could you use the aborted condition in a post section? It’s also my undestanding from those docs that you can put a post-block within a stage, not just at the end of the pipeline, so you could still preserve information about the stage to send to Slack.

May I ask what your specific aversion to using a POST section is?

Colin

Hi Idan,

Does this idea make sense to you?

https://jira.sonarsource.com/browse/SONARJNKNS-297

Yes, that’ll work quite well!

I was actually reffering to a POST section for the stage because I’m already using the global POST, and I didn’t want to have two slack messages sent, one from each POST failure. But anyway I worked around it for now.

Julian’s waitForQualityGate enhancement would be great to have.

@Julien_HENRY, does abortPipeline: true set currentBuild to FAILURE?

I think so, but this is not totally obvious from pipeline API: