-
Notifications
You must be signed in to change notification settings - Fork 0
[SD-324] Jira test notification #56
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
Merged
Merged
Changes from all commits
Commits
Show all changes
62 commits
Select commit
Hold shift + click to select a range
c144297
rough jira noti
klaukl b958d69
rough jira noti
klaukl 332564c
test
klaukl d98c684
test
klaukl 85a4420
test
klaukl 46f7562
removed unused
klaukl 9d9cae6
test
klaukl b81dad3
test
klaukl a7bbbf7
test
klaukl a6c72ca
test
klaukl c8fb1fa
noid
klaukl d3e5dac
test
klaukl e5acf58
test
klaukl d7b08b9
test
klaukl c6f8edd
test id not exist
klaukl 3a31112
test
klaukl a598c8d
cleanup
klaukl 9fcbeb9
rename
klaukl e4801c8
rename
klaukl f002458
cleanup
klaukl dc05ef7
cleanup
klaukl 8b58e41
cleanup
klaukl b23e2bf
cleanup
klaukl 418720f
cleanup
klaukl 4ec1728
cleanup
klaukl e2171c6
cleanup
klaukl 3add18c
cleanup
klaukl 31ca2a6
split
klaukl 2c77a96
split
klaukl 818f6d6
split
klaukl 872484e
split
klaukl 1da0638
split
klaukl 233ace3
SCFA-898 test
klaukl 051f68d
split
klaukl 63a6c1d
split
klaukl 34c5bd3
split
klaukl cc7d1b4
split
klaukl 464137d
split
klaukl a225a5b
test
klaukl 1943845
inputs
klaukl c7b0e39
inputs
klaukl d6e2295
moved post jira notification out
klaukl 72d4601
moved post jira notification out
klaukl d26259f
moved post jira notification out
klaukl 6184f49
moved post jira notification out
klaukl 9c1dd86
moved post jira notification out
klaukl ba3abbc
SCFA-898 test
klaukl 3723cc6
SCFA-898 test
klaukl 8e47617
SCFA-898 test
klaukl c873bea
SCFA-898 test
klaukl 53a7d18
rename
klaukl e31bf42
rename
klaukl 33d8c98
remove status and use input
klaukl ace0551
remove comment env var
klaukl 868756f
prep name job
klaukl 233e022
prep name job
klaukl c89c7e1
comment
klaukl ef66090
review comments
klaukl 73ef98f
review comments step sum
klaukl 555f2b5
review comments step sum
klaukl fb0aa06
review comments step sum
klaukl 658a724
Merge branch 'main' into SD-324-e2e-jira-v2
klaukl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| name: post_jira_comment | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| jira_id: | ||
| type: string | ||
| required: true | ||
| default: "" | ||
| comment: | ||
| type: string | ||
| required: true | ||
| default: "" | ||
|
|
||
| jobs: | ||
| post_jira_comment: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Post JIRA Comment | ||
| id: post_jira_comment | ||
| env: | ||
| JIRA_USERNAME: ${{ secrets.JIRA_USERNAME }} | ||
| JIRA_PASSWORD: ${{ secrets.JIRA_PASSWORD }} | ||
| run: | | ||
| echo "Received JIRA ID: ${{ inputs.jira_id }}" | ||
| echo "Received COMMENT: ${{ inputs.comment }}" | ||
|
|
||
| # Define the JIRA comment API endpoint | ||
| JIRA_API_URL="https://digital-vic.atlassian.net/rest/api/2/issue/${{ inputs.jira_id }}/comment" | ||
|
|
||
| # Post the comment to JIRA using basic auth with username and password | ||
| response=$(curl -s -w "%{http_code}" -X POST \ | ||
| -H "Content-Type: application/json" \ | ||
| -u "${JIRA_USERNAME}:${JIRA_PASSWORD}" \ | ||
| --data "{\"body\": \"${{ inputs.comment }}\"}" \ | ||
| "${JIRA_API_URL}") | ||
|
|
||
| http_code="${response:(-3)}" # Extract HTTP status code (last 3 characters) | ||
| response_body="${response:0:-3}" # The response body | ||
|
|
||
| # Handle the API response | ||
| if [ "$http_code" -eq 201 ]; then | ||
| echo "Comment posted successfully to Jira issue ${{ inputs.jira_id }}" | ||
| echo "Response Body: $response_body" | ||
| else | ||
| echo "Failed to post comment to Jira issue ${{ inputs.jira_id }}. HTTP Code: $http_code" | ||
klaukl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| echo "Response Body: $response_body" | ||
|
|
||
| echo '### ⚠️ Failed to post comment to Jira' >> $GITHUB_STEP_SUMMARY | ||
| echo "#### Issue ID: ${{ inputs.jira_id }}" >> $GITHUB_STEP_SUMMARY | ||
| echo "#### HTTP Code: $http_code" >> $GITHUB_STEP_SUMMARY | ||
| echo "#### Response Body: $response_body" >> $GITHUB_STEP_SUMMARY | ||
|
|
||
| fi | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| name: test_post_jira | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| status: | ||
| type: string | ||
| required: true | ||
| default: "" | ||
|
|
||
| jobs: | ||
| test_prepare_jira: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| jira_id: ${{ steps.extract_jira_id.outputs.jira_id }} | ||
| comment: ${{ steps.prepare_jira_comment.outputs.comment }} | ||
| steps: | ||
| - name: Extract JIRA ID from the commit message | ||
| id: extract_jira_id | ||
| run: | | ||
| # Fetch commit message from the GitHub API | ||
| commit_info=$(curl -L \ | ||
| -H "Accept: application/vnd.github+json" \ | ||
| -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | ||
| https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}) | ||
|
|
||
| # Check if curl was successful | ||
| if [ $? -ne 0 ]; then | ||
| echo "Failed to fetch commit message." | ||
| exit 0 # Exit gracefully on curl failure | ||
| fi | ||
|
|
||
| commit_message=$(echo "$commit_info" | jq -r '.commit.message') | ||
|
|
||
| # Extract JIRA ID | ||
| JIRA_ID=$(echo "$commit_message" | grep -oE 'SCFA-[0-9]{1,5}' || true) # Prevents non-zero exit code | ||
|
|
||
| # Check if JIRA ID is found | ||
| if [ -z "$JIRA_ID" ]; then | ||
| echo "No JIRA ID found in commit message: $commit_message" | ||
| else | ||
| echo "Extracted JIRA ID: $JIRA_ID" | ||
| echo "JIRA_ID=$JIRA_ID" >> $GITHUB_ENV | ||
| echo "jira_id=$JIRA_ID" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Prepare JIRA Comment | ||
| id: prepare_jira_comment | ||
| if: env.JIRA_ID != '' | ||
| env: | ||
| WORKFLOW_LINK: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" # Link to the workflow run | ||
| run: | | ||
| echo "Preparing JIRA comment..." | ||
|
|
||
| # Determine the branch name from the Git reference | ||
| GIT_BRANCH=${GITHUB_REF##*/} | ||
|
|
||
| # Construct the comment template | ||
| COMMENT="E2E Test - ${{ inputs.status }} on branch ${GIT_BRANCH}\n" | ||
| COMMENT+="Workflow URL: $WORKFLOW_LINK" | ||
|
|
||
| # Print the comment to the console for debugging | ||
| echo "comment=$COMMENT" >> "$GITHUB_OUTPUT" | ||
| echo "$COMMENT" | ||
| echo "${{ inputs.status }}" | ||
|
|
||
| post_jira_comment: | ||
| uses: ./.github/workflows/post_jira_comment.yml | ||
| needs: [test_prepare_jira] | ||
| secrets: inherit | ||
| with: | ||
| jira_id: ${{ needs.test_prepare_jira.outputs.jira_id }} | ||
| comment: ${{ needs.test_prepare_jira.outputs.comment }} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.