Trying to stop build when using GitHub Actions

Hello, I am new to SonarQube and trying to navigate the documentation.

I am working for a customer that is using Enterprise Edition Version 8.9 (build 43852). I have added a SonarQube scan to my GitHub repo - that is working fine. I now want to stop a build if there is some kind of scan failure. What is the best way to do this when using GitHub actions?

I’ve done some digging around and it looks like it might be possible in the properties file. I’ve also seen references to putting Dsonar.qualitygate.wait=true in the yml file. Any help in this area would be GREATLY appreciated.

Hi,

Welcome to the community!

There’s an Action for the Quality Gate check that’s probably what you want.

 
HTH,
Ann

Thank you so much! I was able to get it working with that example.

I wonder if you can point me in the direction with something else? I am trying to get some code to fail the Quality Gates that have been set up for me (I can’t edit them). Would you be able to provide an example? I tried duplicating several lines of code - that didn’t work. This is just a POC so I only have a few lines of code.

I found out a hacky way to do this - just change the token so that the scan fails (kind of). If there is a more elegant way to do this I am all ears :-).

I’ve moved on to the next step - trying to prevent the promotion from failing. In my yml file I have sonarqube as the first job and then the other jobs after it. How can I stop processing if scanning fails? Thank you again! @ganncamp

Found my answer: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idneeds

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.