Commit 7d4d8ef4 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '32776-add-slack-notification-for-scheduled-package-and-qa-jobs' into 'master'

Resolve "Add Slack notification for scheduled `package-and-qa` jobs"

See merge request gitlab-org/gitlab!17796
parents 85c4ebe7 28ec3861
...@@ -8,6 +8,7 @@ stages: ...@@ -8,6 +8,7 @@ stages:
- review - review
- qa - qa
- post-test - post-test
- notification
- pages - pages
variables: variables:
...@@ -27,11 +28,12 @@ after_script: ...@@ -27,11 +28,12 @@ after_script:
- date - date
include: include:
- local: .gitlab/ci/global.gitlab-ci.yml
- local: .gitlab/ci/cng.gitlab-ci.yml - local: .gitlab/ci/cng.gitlab-ci.yml
- local: .gitlab/ci/docs.gitlab-ci.yml - local: .gitlab/ci/docs.gitlab-ci.yml
- local: .gitlab/ci/frontend.gitlab-ci.yml - local: .gitlab/ci/frontend.gitlab-ci.yml
- local: .gitlab/ci/global.gitlab-ci.yml
- local: .gitlab/ci/memory.gitlab-ci.yml - local: .gitlab/ci/memory.gitlab-ci.yml
- local: .gitlab/ci/notifications.gitlab-ci.yml
- local: .gitlab/ci/pages.gitlab-ci.yml - local: .gitlab/ci/pages.gitlab-ci.yml
- local: .gitlab/ci/qa.gitlab-ci.yml - local: .gitlab/ci/qa.gitlab-ci.yml
- local: .gitlab/ci/reports.gitlab-ci.yml - local: .gitlab/ci/reports.gitlab-ci.yml
......
...@@ -110,6 +110,12 @@ ...@@ -110,6 +110,12 @@
- $CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE == "gitlab-org" - $CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE == "gitlab-org"
kubernetes: active kubernetes: active
.only-canonical-schedules:
only:
refs:
- schedules@gitlab-org/gitlab
- schedules@gitlab-org/gitlab-foss
.use-pg9: .use-pg9:
services: services:
- name: postgres:9.6 - name: postgres:9.6
......
.notify:
image: alpine
stage: notification
dependencies: []
cache: {}
before_script:
- apk update && apk add git curl bash
schedule:package-and-qa:notify-success:
extends:
- .only-canonical-schedules
- .notify
script:
- 'scripts/notify-slack qa-master ":tada: Scheduled QA against `master` passed! :tada: See $CI_PIPELINE_URL." ci_passing'
needs: ["schedule:package-and-qa"]
when: on_success
schedule:package-and-qa:notify-failure:
extends:
- .only-canonical-schedules
- .notify
script:
- 'scripts/notify-slack qa-master ":skull_and_crossbones: Scheduled QA against `master` failed! :skull_and_crossbones: See $CI_PIPELINE_URL." ci_failing'
needs: ["schedule:package-and-qa"]
when: on_failure
...@@ -38,9 +38,5 @@ schedule:package-and-qa: ...@@ -38,9 +38,5 @@ schedule:package-and-qa:
extends: extends:
- .package-and-qa-base - .package-and-qa-base
- .only-code-qa-changes - .only-code-qa-changes
only: - .only-canonical-schedules
refs:
- schedules@gitlab-org/gitlab
- schedules@gitlab-org/gitlab-foss
needs: ["build-qa-image", "gitlab:assets:compile"] needs: ["build-qa-image", "gitlab:assets:compile"]
allow_failure: true
...@@ -27,6 +27,7 @@ The current stages are: ...@@ -27,6 +27,7 @@ The current stages are:
- `review`: This stage includes jobs that deploy the GitLab and Docs Review Apps. - `review`: This stage includes jobs that deploy the GitLab and Docs Review Apps.
- `qa`: This stage includes jobs that perform QA tasks against the Review App - `qa`: This stage includes jobs that perform QA tasks against the Review App
that is deployed in the previous stage. that is deployed in the previous stage.
- `notification`: This stage includes jobs that sends notifications about pipeline status.
- `post-test`: This stage includes jobs that build reports or gather data from - `post-test`: This stage includes jobs that build reports or gather data from
the previous stages' jobs (e.g. coverage, Knapsack metadata etc.). the previous stages' jobs (e.g. coverage, Knapsack metadata etc.).
- `pages`: This stage includes a job that deploys the various reports as - `pages`: This stage includes a job that deploys the various reports as
...@@ -191,6 +192,11 @@ subgraph "`qa` stage" ...@@ -191,6 +192,11 @@ subgraph "`qa` stage"
dast -.-> |depends on| G; dast -.-> |depends on| G;
end end
subgraph "`notification` stage"
NOTIFICATION1["schedule:package-and-qa:notify-success<br>(on_success)"] -.-> |needs| P;
NOTIFICATION2["schedule:package-and-qa:notify-failure<br>(on_failure)"] -.-> |needs| P;
end
subgraph "`post-test` stage" subgraph "`post-test` stage"
M M
end end
......
#!/bin/bash
# Sends Slack notification MSG to CI_SLACK_WEBHOOK_URL (which needs to be set).
# ICON_EMOJI needs to be set to an icon emoji name (without the `:` around it).
CHANNEL=$1
MSG=$2
ICON_EMOJI=$3
if [ -z "$CHANNEL" ] || [ -z "$CI_SLACK_WEBHOOK_URL" ] || [ -z "$MSG" ] || [ -z "$ICON_EMOJI" ]; then
echo "Missing argument(s) - Use: $0 channel message icon_emoji"
echo "and set CI_SLACK_WEBHOOK_URL environment variable."
else
curl -X POST --data-urlencode 'payload={"channel": "#'"$CHANNEL"'", "username": "GitLab QA Bot", "text": "'"$MSG"'", "icon_emoji": "'":$ICON_EMOJI:"'"}' "$CI_SLACK_WEBHOOK_URL"
fi
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment