cloud-native-toolkit / cloud-native-toolkit/planning
Sonar scan task should be able to wait and check results
- Dominant language
- No language data
- Stars
- 4
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
**Is your feature request related to a problem? Please describe.**
Currently, in the default Pipeline the test task does a sonar scan, but the task is missing the ability to failed the pipeline if the scan results cause errors in the project.
**Which persona(s) does this feature benefit (e.g. developer, SRE, etc)?**
Maureen the Developer
**What is the impact of not having this feature? What will be the benefit of having this feature?**
It would be of great help not to do the check manually on every pipeline run
**Describe the solution you'd like**
The task could be split into a separate task just for sonar things, and provide a parameter to optionally check for results or not.
**Additional context**
This came up as feedback from Grzegorz Smolko while showing the toolkit to client, wanted to demonstrate how the pipeline can catch problems.
Here is a POC of the code that checks
```
image: $(params.js-image)
name: sonar-check
resources: {}
script: |
APP_NAME=$(params.app-name)
if [ -n "${SONARQUBE_URL}" ]; then
response=$(curl --head --write-out %{http_code} --silent --output /dev/null -u ${SONARQUBE_USER}:${SONARQUBE_PASSWORD} ${SONARQUBE_URL}/api/qualitygates/project_status?projectKey=${APP_NAME})
echo "Response: $response"
while [ $response -eq '404' ]; do
sleep 10
echo "Trying again to see if scan is done"
response=$(curl --head --write-out %{http_code} --silent --output /dev/null -u ${SONARQUBE_USER}:${SONARQUBE_PASSWORD} ${SONARQUBE_URL}/api/qualitygates/project_status?projectKey=${APP_NAME})
done
response=$(curl --silent -u ${SONARQUBE_USER}:${SONARQUBE_PASSWORD} ${SONARQUBE_URL}/api/qualitygates/project_status?projectKey=${APP_NAME})
if echo $response | grep -q "\"projectStatus\":{\"status\":\"ERROR\""; then
echo "====== Gate value failed: $response"
exit 1;
else
echo "====== Gate value passed! ======"
fi
else
echo "Skipping Sonar Qube step"
fi
workingDir: $(params.source-dir)
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.