Skip to content

Commit 7e0c563

Browse files
authored
updated sonarqube plugin script (#2855)
1 parent 3e5f548 commit 7e0c563

File tree

1 file changed

+22
-31
lines changed

1 file changed

+22
-31
lines changed

scripts/sql/106_sonarqube_plugin_polling.up.sql

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,39 +16,30 @@ VALUES(nextval('id_seq_plugin_step_variable'),2,'AbortPipelineOnPolicyCheckFaile
1616

1717
UPDATE plugin_pipeline_script SET script=E'PathToCodeDir=/devtroncd$CheckoutPath
1818
cd $PathToCodeDir
19-
if [[ -z "$UsePropertiesFileFromProject" ]]
19+
if [[ -z "$UsePropertiesFileFromProject" || $UsePropertiesFileFromProject == false ]]
2020
then
2121
echo "sonar.projectKey=$SonarqubeProjectKey" > sonar-project.properties
22-
docker run \\
23-
--rm \\
24-
-e SONAR_HOST_URL=$SonarqubeEndpoint \\
25-
-e SONAR_LOGIN=$SonarqubeApiKey \\
26-
-v "/$PWD:/usr/src" \\
27-
sonarsource/sonar-scanner-cli
28-
elif [[ $UsePropertiesFileFromProject == false ]]
29-
then
30-
echo "sonar.projectKey=$SonarqubeProjectKey" > sonar-project.properties
31-
docker run \\
32-
--rm \\
33-
-e SONAR_HOST_URL=$SonarqubeEndpoint \\
34-
-e SONAR_LOGIN=$SonarqubeApiKey \\
35-
-v "/$PWD:/usr/src" \\
36-
sonarsource/sonar-scanner-cli
22+
fi
23+
docker run \\
24+
--rm \\
25+
-e SONAR_HOST_URL=$SonarqubeEndpoint \\
26+
-e SONAR_LOGIN=$SonarqubeApiKey \\
27+
-v "/$PWD:/usr/src" \\
28+
sonarsource/sonar-scanner-cli
3729
38-
if [[ $CheckForSonarAnalysisReport == true && ! -z "$CheckForSonarAnalysisReport" ]]
30+
if [[ $CheckForSonarAnalysisReport == true && ! -z "$CheckForSonarAnalysisReport" ]]
31+
then
32+
status=$(curl -u ${SonarqubeApiKey}: -sS ${SonarqubeEndpoint}/api/qualitygates/project_status?projectKey=${SonarqubeProjectKey}&branch=master)
33+
project_status=$(echo $status | jq -r ".projectStatus.status")
34+
echo "********* SonarQube Policy Report *********"
35+
echo $status
36+
if [[ $AbortPipelineOnPolicyCheckFailed == true && $project_status == "ERROR" ]]
37+
then
38+
echo "********* SonarQube Policy Violated *********"
39+
echo "********* Exiting Build *********"
40+
exit
41+
elif [[ $AbortPipelineOnPolicyCheckFailed == true && $project_status == "OK" ]]
3942
then
40-
status=$(curl -u ${SonarqubeApiKey}: -sS ${SonarqubeEndpoint}/api/qualitygates/project_status?projectKey=${SonarqubeProjectKey}&branch=master)
41-
project_status=$(echo $status | jq -r ".projectStatus.status")
42-
echo "********* SonarQube Policy Report *********"
43-
echo $status
44-
if [[ $AbortPipelineOnPolicyCheckFailed == true && $project_status == "ERROR" ]]
45-
then
46-
echo "********* SonarQube Policy Violated *********"
47-
echo "********* Exiting Build *********"
48-
exit
49-
elif [[ $AbortPipelineOnPolicyCheckFailed == true && $project_status == "OK" ]]
50-
then
51-
echo "********* SonarQube Policy Passed *********"
52-
fi
43+
echo "********* SonarQube Policy Passed *********"
5344
fi
54-
fi' WHERE id=2;
45+
fi' WHERE id=2;

0 commit comments

Comments
 (0)