@@ -121,7 +121,7 @@ spec:
121121 - name : sourceDataArtifact
122122 value : $(params.sourceDataArtifact)
123123 - name : close-issues
124- image : quay.io/konflux-ci /release-service-utils@sha256:5546fa78d3c88d7b6a2e8cff8902f7757f00541d0bbaf113b9f293133894afa3
124+ image : quay.io/jbieren /release-service-utils:closeissues_2
125125 computeResources :
126126 limits :
127127 memory : 32Mi
@@ -131,86 +131,16 @@ spec:
131131 volumeMounts :
132132 - name : access-token-secret-vol
133133 mountPath : " /etc/secrets"
134- script : |
135- #!/usr/bin/env bash
136- # We do not set -x here because it would leak the ACCESS_TOKEN
137- set -eu
138-
139- ACCESS_TOKEN="$(cat /etc/secrets/token)"
140- EMAIL="$(cat /etc/secrets/email)"
141-
142- ISSUE_TRACKERS='{
143- "Jira": {
144- "api": "rest/api/2/issue",
145- "servers": [
146- "issues.redhat.com",
147- "jira.atlassian.com",
148- "redhat.atlassian.net"
149- ]
150- },
151- "bugzilla": {
152- "api": "rest/bug",
153- "servers": [
154- "bugzilla.redhat.com"
155- ]
156- }
157- }'
158-
159- DATA_FILE="$(params.dataDir)/$(params.dataPath)"
160- if [ ! -f "${DATA_FILE}" ] ; then
161- echo "No data JSON was provided."
162- exit 1
163- fi
164-
165- NUM_ISSUES=$(jq -cr '.releaseNotes.issues.fixed | length' "${DATA_FILE}")
166- for ((i = 0; i < NUM_ISSUES; i++)); do
167- issue=$(jq -c --argjson i "$i" '.releaseNotes.issues.fixed[$i]' "${DATA_FILE}")
168- server=$(jq -r '.source' <<< "$issue")
169- if [ "$server" = "issues.redhat.com" ] ; then
170- server=redhat.atlassian.net
171- fi
172- if [ "$server" != "redhat.atlassian.net" ] ; then
173- echo "This task currently only supports closing issues on issues.redhat.com"
174- echo "and redhat.atlassian.net. Skipping issue $issue as it is on $server"
175- continue
176- fi
177-
178- CURL_ARGS=(-u "${EMAIL}:${ACCESS_TOKEN}")
179-
180- API=$(jq -r '.[] | select(.servers[] | contains("'"$server"'")) | .api' <<< "$ISSUE_TRACKERS")
181- API_URL="https://${server}/${API}/$(jq -r '.id' <<< "$issue")"
182-
183- if [ "$(curl-with-retry "${CURL_ARGS[@]}" "${API_URL}" | jq -r '.fields.status.name')" == "Closed" ] ; then
184- echo "Issue $issue is already in Closed state. Skipping it."
185- continue
186- fi
187-
188- echo "Closing issue $issue"
189- CLOSE_COMMENT="Fixed in Konflux Advisory $(params.advisoryUrl)"
190- CLOSING_RC=0
191- # Get the Closed transition id. This varies per Jira project
192- if ! CLOSED_ID="$(curl-with-retry "${CURL_ARGS[@]}" "${API_URL}/transitions" \
193- | jq -er '.transitions[] | select(.name=="Closed") | .id')"; then
194- echo "Warning: failed to fetch the closed state id for issue $issue. We most likely do not have" \
195- "permission to close it. Will try to add a comment instead."
196- CLOSING_RC=1
197- # Close the issue
198- elif ! curl-with-retry "${CURL_ARGS[@]}" -XPOST --data \
199- '{"transition":{"id":"'"$CLOSED_ID"'"},"update":{"comment":[{"add":{"body":"'"$CLOSE_COMMENT"'"}}]}}' \
200- -H "Content-Type: application/json" "${API_URL}/transitions"; then
201- echo "Warning: failed to close issue $issue. Will try to add a comment instead."
202- CLOSING_RC=1
203- fi
204-
205- if [ "$CLOSING_RC" -ne 0 ] ; then
206- # Try to add the comment even if closing failed
207- if ! curl-with-retry "${CURL_ARGS[@]}" -XPOST --data \
208- '{"body":"'"$CLOSE_COMMENT"'"}' \
209- -H "Content-Type: application/json" "${API_URL}/comment"; then
210- echo "Warning: failed to add comment to issue $issue."
211- fi
212- fi
213- done
134+ env :
135+ - name : PARAM_DATA_DIR
136+ value : $(params.dataDir)
137+ - name : PARAM_DATA_PATH
138+ value : $(params.dataPath)
139+ - name : PARAM_ADVISORY_URL
140+ value : $(params.advisoryUrl)
141+ - name : JIRA_SECRET_PATH
142+ value : /etc/secrets
143+ command : ["/home/scripts/python/tasks/managed/close_advisory_issues.py"]
214144 - name : create-trusted-artifact
215145 computeResources :
216146 limits :
0 commit comments