Skip to content
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

Concourse Bot not Outputting to Ask Channel #6578

Open
9 tasks
timckt opened this issue Dec 17, 2024 · 1 comment
Open
9 tasks

Concourse Bot not Outputting to Ask Channel #6578

timckt opened this issue Dec 17, 2024 · 1 comment
Assignees

Comments

@timckt
Copy link
Contributor

timckt commented Dec 17, 2024

Background

When user merged a PR and got error in apply-namespace-changes-live pipeline, Concourse Bot does not reply to Ask Channel user with error pipeline link.

Investigate and fix it.

Proposed user journey

Approach

Which part of the user docs does this impact

Communicate changes

  • post for #cloud-platform-update
  • Weeknotes item
  • Show the Thing/P&A All Hands/User CoP
  • Announcements channel

Questions / Assumptions

Definition of done

  • readme has been updated
  • user docs have been updated
  • another team member has reviewed
  • smoke tests are green
  • prepare demo for the team

Reference

How to write good user stories

@timckt timckt self-assigned this Dec 23, 2024
@timckt timckt moved this from Todo to 🏗 In Progress in Cloud Platform Dec 27, 2024
@timckt
Copy link
Contributor Author

timckt commented Dec 30, 2024

Root Cause

The problem should be with the Concourse variable BUILD_URL.

Take this Slack Message for PR with pipeline error as example.

the variable BUILD_URL is as below:, there is an extra created, in the output.

→ curl -L \
                  -H "Accept: application/vnd.github+json" \
                  -H "Authorization: Bearer $GITHUB_TOKEN" \
                  -H "X-GitHub-Api-Version: 2022-11-28" \
                  "https://api.github.com/repos/ministryofjustice/cloud-platform-environments/issues/$PR/comments" | jq '.[].body' | awk '{print $9}' | tr -d '"'

Output:

created,
https://concourse.cloud-platform.service.justice.gov.uk/teams/main/pipelines/environments-live/jobs/apply-namespace-changes-live/builds/9493

The unexpected created, caused the notifyUserApplyFailed cannot work properly and cannot send message to Slack.

The extra created, comes from the newly added terraform plan summary body.

Solution

Update the BUILD_URL curl command to:

  • Extract only the Concourse build link
  • Ensure that the extracted URL corresponds to the latest build (e.g., if builds are rerun, the output might include 100, 100.1, 100.2, etc., and the latest URL should be captured—100.2).

Updated curl command

→ curl -L \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer $GITHUB_TOKEN" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  "https://api.github.com/repos/ministryofjustice/cloud-platform-environments/issues/$PR/comments" \
  | jq -r '.[]
  | select(.body | contains("Your PR is applying in the build:"))
  | .body' \
  | awk '{print $8}' \
  | tail -n 1

Updated Output

https://concourse.cloud-platform.service.justice.gov.uk/teams/main/pipelines/environments-live/jobs/apply-namespace-changes-live/builds/9493.1

After updating the curl command, Concourse bot can send message with the latest build URL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🏗 In Progress
Development

No branches or pull requests

2 participants