We have implemented a scan pipe in BBC Pipelines a couple of months ago which allows users to seamlessly add a SonarCloud scan in their Pipeline. While this is a good first step, we want to add the possibility to make the pipeline fail whenever the Quality Gate failed.
The pipe will wait for the Quality Gate result to be available and stop the pipe if the quality gate failed (with the details displayed in the logs to let the user know what broke the QG - and with the URL to the project dashboard), or let the pipe continue otherwise (in which case the logs should just display that everything's OK).
To get the result of the Quality Gate, the pipe will actively poll the SonarCloud API until the result is available. That means when the pipe wait for the Quality Gate to be available, build minutes will be consumed. This information should be crystal clear for the user as it might increase a lot their build minutes and therefore the cost of BBC Pipelines. All this should be documented on the Pipe itself.
This pipe should have the following parameter:
- timeout (default: 300s) => if the report is not processed after this timeout, the pipe should stop the pipeline
This pipe will be implemented using a Docker image which needs to get access to the analysis-report.txt file from the previous pipe or step. This challenge can probably be overcome with the "Data sharing for pipes" improvement listed below.
At the same time, we could improve the first pipe:
- Automatic injection of SONAR_TOKEN variable
- Data sharing for pipes => this is what could be used to get access to the analysis-report.txt file from the previous pipe.