-
Notifications
You must be signed in to change notification settings - Fork 1
DEVOPS-853: check jira issue #147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| - name: Check issue key | ||
| if: ${{ !steps.jira_key_from_title.outputs.issue_key }} | ||
| run: | | ||
| echo "Could not determine Jira issue from PR title" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably TODO: add exceptions for Dependabot etc PRs.
10650e3 to
4d59de0
Compare
sebhmg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see suggestion to merge workflows, and use a more specific pattern
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it might run too soon. Somehow, we want it executed after pr_add_jira_summary
Possibly just have "Check issue status" as an extra step in pr_add_jira_summary.
However, "Check issue status" must reran at every push (e.g. to error out when pushing to a closed issue).
My suggesting: merge the two workflow into one "Check Jira Status", with "Check JIRA issue status" step last:
- if trigger by
pull_request[opened], run all steps - if trigger is
pull_request[synchronize, reopened, ready_for_review], only run steps:- Find JIRA issue key from title
- Check JIRA issue status
Not finding JIRA from title is not an error.
Possible, use a secret to configure the pattern of supported key, e.g. "\b(NI|SHRUB|BEAST|AARG|SWALLOW|TIM|BRIDGE)[-# ]*([0-9]+)"
sebhmg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please, see questions and suggestions
| if: ${{ !steps.jira_key_from_title.outputs.issue_key }} | ||
| run: | | ||
| echo "Could not determine Jira issue from PR title" | ||
| exit 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: do not make it a failure. Skipping following steps with condition is enough
| exit 1 | ||
| fi | ||
| echo "response was: $(echo $response|jq)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: logging the response can be a big chunk in log. Could this be done only if running workflow in debug mode?
| if [ $? -ne 0 ]; then | ||
| echo "Jira API: error" | ||
| exit 1 | ||
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: instead use set -e at the top of the script
although, it might be interesting to see the response. Will it show in stderror in any case?
| echo "Checking if issue is In Progress" | ||
| status=$(echo $response| jq -r '.issues[0].fields.statusCategory.name') | ||
| if [ "$status" != "In Progress" ]; then | ||
| error="$error Error: Jira issue is not In Progress" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: have a line break between errors
error="$error\n Error: Jira issue is not In Progress"
| "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/pulls/${{ github.event.pull_request.number }}" | ||
| > /dev/null | ||
| check_jira_issue: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: upon PR opened, must ensure this jobs runs after add_jira_summary
So the JIRA issue number is in the title. Or use the same logic to fetch the jira issue: title plus branch name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alternatively have a single job, where steps runs only upon opened, except for jira_key_from_title and "Check issue status" which also run
| - name: Find JIRA issue key from title | ||
| id: jira_key_from_title | ||
| if: ${{ !steps.jira_summary_from_branch.outputs.summary }} | ||
| env: | ||
| PR_TITLE: ${{ github.event.pull_request.title }} | ||
| run: > | ||
| echo "issue_key=$( | ||
| echo $PR_TITLE | grep -osiE "^\s*\[?\s*$JIRA_PATTERN" | ||
| | head -n1 | sed -E "s/\W*$JIRA_PATTERN/\1-\2/i" | ||
| | tr [:lower:] [:upper:] | ||
| )" >> $GITHUB_OUTPUT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: make this a reusable action to use in both jobs
This reverts commit a4460f1.
DEVOPS-853 - Update Jenkinslib -- Jira API for querying issues is deprecated