@@ -35,6 +35,40 @@ pipeline:
3535 arch : Amd64
3636 execution :
3737 steps :
38+ - step :
39+ type : Run
40+ name : Post Quality Gate to GitHub
41+ identifier : Post_Quality_Gate_to_GitHub
42+ spec :
43+ shell : Sh
44+ command : |-
45+ # Get SonarQube quality gate status
46+ curl -u <+secrets.getValue("sonarqube_token")>: \
47+ -s "https://sonar.harness.io/api/qualitygates/project_status?projectKey=python-client&pullRequest=${<+codebase.prNumber>}"
48+ QUALITY_GATE_STATUS=$(curl -u <+secrets.getValue("sonarqube_token")> :\
49+ -s "https://sonar.harness.io/api/qualitygates/project_status?projectKey=python-client&pullRequest=${<+codebase.prNumber>}" \
50+ | jq -r '.projectStatus.status')
51+
52+ # Set GitHub status based on quality gate
53+ if [ "$QUALITY_GATE_STATUS" = "OK" ]; then
54+ STATE="success"
55+ DESCRIPTION="SonarQube Quality Gate passed"
56+ else
57+ STATE="failure"
58+ DESCRIPTION="SonarQube Quality Gate failed"
59+ fi
60+
61+ # Post status to GitHub
62+ curl -X POST \
63+ -H "Authorization: token <+secrets.getValue("github_token")>" \
64+ -H "Content-Type: application/json" \
65+ -d "{
66+ \"state\": \"$STATE\",
67+ \"description\": \"$DESCRIPTION\",
68+ \"context\": \"sonarqube/qualitygate\",
69+ \"target_url\": \"https://sonar.harness.io/dashboard?id=python-client&pullRequest=<+codebase.prNumber>\"
70+ }" \
71+ "https://api.github.com/repos/splitio/python-client/statuses/<+codebase.commitSha>"
3872 - step :
3973 type : Run
4074 name : Install and Run SonarQube Scanner
@@ -71,40 +105,6 @@ pipeline:
71105 outputVariables :
72106 - name : SONAR_SCANNER_PATH
73107 timeout : 10m
74- - step :
75- type : Run
76- name : Post Quality Gate to GitHub
77- identifier : Post_Quality_Gate_to_GitHub
78- spec :
79- shell : Sh
80- command : |-
81- # Get SonarQube quality gate status
82- curl -s -u <+secrets.getValue("sonarqube_token")> \
83- "https://sonar.harness.io/api/qualitygates/project_status?projectKey=python-client&pullRequest=${<+codebase.prNumber>}"
84- QUALITY_GATE_STATUS=$(curl -s -u <+secrets.getValue("sonarqube_token")> \
85- "https://sonar.harness.io/api/qualitygates/project_status?projectKey=python-client&pullRequest=${<+codebase.prNumber>}" \
86- | jq -r '.projectStatus.status')
87-
88- # Set GitHub status based on quality gate
89- if [ "$QUALITY_GATE_STATUS" = "OK" ]; then
90- STATE="success"
91- DESCRIPTION="SonarQube Quality Gate passed"
92- else
93- STATE="failure"
94- DESCRIPTION="SonarQube Quality Gate failed"
95- fi
96-
97- # Post status to GitHub
98- curl -X POST \
99- -H "Authorization: token <+secrets.getValue("github_token")>" \
100- -H "Content-Type: application/json" \
101- -d "{
102- \"state\": \"$STATE\",
103- \"description\": \"$DESCRIPTION\",
104- \"context\": \"sonarqube/qualitygate\",
105- \"target_url\": \"https://sonar.harness.io/dashboard?id=python-client&pullRequest=<+codebase.prNumber>\"
106- }" \
107- "https://api.github.com/repos/splitio/python-client/statuses/<+codebase.commitSha>"
108108 - step :
109109 timeout : 30m
110110 type : Test
0 commit comments