|
replyCallback: async (pipeline) => { |
|
const pauseCause = getPauseCause(pipeline); |
|
|
|
if (pauseCause == null) return []; |
|
const [base, head] = await getBaseAndHeadCommit(pipeline); |
|
const authors = head ? await getAuthors('getsentry', base, head) : []; |
|
// Get unique users from the authors |
|
const uniqueUsers = await getUniqueUsers(authors); |
|
|
|
// Pick at most 10 users to cc |
|
const ccUsers = uniqueUsers.slice(0, 10); |
|
const ccString = ccUsers |
|
.map((user) => { |
|
return `<@${user.slackUser}>`; |
|
}) |
|
.join(' '); |
|
|
|
const failedJob = pipeline.stage.jobs.find( |
|
(job) => job.result.toLowerCase() === 'failed' |
|
); |
|
if (!failedJob) { |
|
// This should never happen, but if it does, we want to know about it |
|
Sentry.captureException( |
|
new Error('Failed to find failed job in failed pipeline') |
|
); |
|
return []; |
|
} |
|
const gocdLogsLink = `https://deploy.getsentry.net/go/tab/build/detail/${pipeline.name}/${pipeline.counter}/${pipeline.stage.name}/${pipeline.stage.counter}/${failedJob.name}`; |
|
const sentryReleaseLink = pipeline.name.includes('s4s') |
|
? `https://sentry-st.sentry.io/releases/backend@${head}/?project=1513938` |
|
: `https://sentry.sentry.io/releases/backend@${head}/?project=1`; |
|
|
|
const blocks = [ |
|
header( |
|
plaintext(`:double_vertical_bar: ${pipeline.name} has been paused`) |
|
), |
|
section( |
|
markdown(`The deployment pipeline has been paused due to detected issues in ${pauseCause}. Here are the steps you should follow to address the situation:\n |
|
:mag_right: *Step 1: Review the Errors*\n Review the errors in the *<${gocdLogsLink}|GoCD Logs>*.\n |
|
:sentry: *Step 2: Check Sentry Release*\n Check the *<${sentryReleaseLink}|Sentry Release>* for any related issues.\n |
|
:thinking_face: *Step 3: Is a Rollback Necessary?*\nDetermine if a rollback is necessary by reviewing our *<${IS_ROLLBACK_NECESSARY_LINK}|Guidelines>*.\n |
|
:arrow_backward: *Step 4: Rollback Procedure*\nIf a rollback is necessary, use the *<${ROLLBACK_PLAYBOOK_LINK}|GoCD Playbook>* or *<${GOCD_USER_GUIDE_LINK}|GoCD User Guide>* to guide you.\n |
|
:arrow_forward: *Step 5: Unpause the Pipeline*\nWhether or not a rollback was necessary, make sure to unpause the pipeline once it is safe to do so.`) |
|
), |
|
]; |
|
if (ccUsers.length > 0) { |
|
blocks.push( |
|
context( |
|
markdown( |
|
`cc'ing the following ${ |
|
uniqueUsers.length > 10 ? `10 of ${uniqueUsers.length} ` : '' |
|
}people who have commits in this deploy:\n${ccString}` |
|
) |
|
) |
|
); |
|
} |
|
return blocks; |
|
}, |
For a while we only ever had one usage of replyCallback:
eng-pipes/src/brain/gocdSlackFeeds/index.ts
Lines 236 to 293 in f4b4c07