Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ci-operator/step-registry/osac-project/notify/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
approvers:
- osac-cicd
reviewers:
- osac-cicd
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

set -euo pipefail

WEBHOOK_URL="$(cat /var/run/vault/osac-slack-webhook/url)"
PROW_URL="https://prow.ci.openshift.org/view/gs/test-platform-results"

if [[ "${JOB_TYPE:-}" != "periodic" ]]; then
echo "Skipping Slack notification for non-periodic job (type: ${JOB_TYPE:-unknown})"
exit 0
fi

JOB_URL="${PROW_URL}/logs/${JOB_NAME}/${BUILD_ID}"

RESULT="UNKNOWN"
EMOJI=":white_circle:"
if [[ -f "${SHARED_DIR}/test-result" ]]; then
RESULT=$(cat "${SHARED_DIR}/test-result")
fi
if [[ "${RESULT}" == "PASSED" ]]; then
EMOJI=":large_green_circle:"
elif [[ "${RESULT}" == "FAILED" ]]; then
EMOJI=":red_circle:"
fi

VERSIONS=""
if [[ -f "${SHARED_DIR}/versions.txt" ]]; then
while IFS= read -r line; do
VERSIONS="${VERSIONS}\n${line}"
done < "${SHARED_DIR}/versions.txt"
fi

MESSAGE="${EMOJI} *${JOB_NAME}* — ${RESULT}\n<${JOB_URL}|View logs>"
if [[ -n "${VERSIONS}" ]]; then
MESSAGE="${MESSAGE}\n\n*Versions:*\n\`\`\`${VERSIONS}\n\`\`\`"
fi

curl --fail --silent --show-error \
--connect-timeout 10 --max-time 30 \
-X POST -H 'Content-type: application/json' \
--data "{\"text\":\"${MESSAGE}\"}" \
"${WEBHOOK_URL}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"path": "osac-project/notify/osac-project-notify-ref.yaml",
"owners": {
"approvers": [
"osac-cicd"
],
"reviewers": [
"osac-cicd"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ref:
as: osac-project-notify
best_effort: true
from: dev-scripts
timeout: 5m0s
commands: osac-project-notify-commands.sh
credentials:
- namespace: test-credentials
name: osac-slack-webhook
mount_path: /var/run/vault/osac-slack-webhook
resources:
requests:
cpu: 100m
memory: 200Mi
documentation: |-
Sends a Slack notification with the job result and a link to the Prow logs.