Skip to content

Commit 4d59de0

Browse files
andrewg-mirasebhmg
authored andcommitted
DEVOPS-853 add check for Jira issue In Progress
1 parent da9ef2e commit 4d59de0

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

.github/workflows/reusable-jira-pr_check_issue.yml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,36 @@ jobs:
5050
- name: Check issue status
5151
if: ${{ steps.jira_key_from_title.outputs.issue_key }}
5252
run: |
53-
echo "Checking if issue is in open or future sprint"
5453
jql="Sprint in (openSprints(), futureSprints()) and issue=${{ steps.jira_key_from_title.outputs.issue_key }}"
5554
jqlencoded=$(jq -R -r @uri <<<"$jql")
5655
response=$(curl -s --request GET \
57-
--url $JIRA_BASE_URL/rest/api/3/search/jql?jql=$jqlencoded \
56+
--url "$JIRA_BASE_URL/rest/api/3/search/jql?jql=$jqlencoded&fields=statusCategory" \
5857
--user "${JIRA_USER_EMAIL}:${JIRA_API_TOKEN}" \
5958
--header 'Accept: application/json' \
60-
--header 'Content-Type: application/json' | jq '.issues | length')
59+
--header 'Content-Type: application/json')
6160
6261
if [ $? -ne 0 ]; then
6362
echo "Jira API: error"
6463
exit 1
6564
fi
6665
67-
if [ $response -eq 0 ]; then
68-
echo "Error: Jira issue is not in open or future sprint"
66+
echo "response was: $(echo $response|jq)"
67+
error=""
68+
69+
echo "Checking if issue is in open or future sprint"
70+
sprint=$(echo $response | jq '.issues | length')
71+
if [ $sprint -eq 0 ]; then
72+
error="Error: Jira issue is not in open or future sprint"
73+
fi
74+
75+
echo "Checking if issue is In Progress"
76+
status=$(echo $response| jq -r '.issues[0].fields.statusCategory.name')
77+
if [ "$status" != "In Progress" ]; then
78+
error="$error Error: Jira issue is not In Progress"
79+
fi
80+
81+
if [[ ! -z "$error" ]]; then
82+
echo $error
6983
exit 1
7084
fi
7185
72-
echo "response was: $response"

0 commit comments

Comments
 (0)