Compare commits
3 commits
007994e0a2
...
04758f81f2
Author | SHA1 | Date | |
---|---|---|---|
Bruno BELANYI | 04758f81f2 | ||
Bruno BELANYI | eebe509b02 | ||
Bruno BELANYI | 0bc11d85d5 |
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
description = "Ambroisie's blog";
|
description = "A simple Matrix notifier for CI purposes";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
futils = {
|
futils = {
|
||||||
|
@ -75,7 +75,7 @@
|
||||||
|
|
||||||
matrix-notifier = pkgs.stdenvNoCC.mkDerivation rec {
|
matrix-notifier = pkgs.stdenvNoCC.mkDerivation rec {
|
||||||
pname = "matrix-notifier";
|
pname = "matrix-notifier";
|
||||||
version = "0.2.0";
|
version = "0.3.0";
|
||||||
|
|
||||||
src = ./matrix-notifier;
|
src = ./matrix-notifier;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ usage() {
|
||||||
print_err " which message type should be sent must be one of"
|
print_err " which message type should be sent must be one of"
|
||||||
print_err " 'text' or 'notice', or 'auto'."
|
print_err " 'text' or 'notice', or 'auto'."
|
||||||
print_err " The special value 'auto' defaults to 'notice', unless"
|
print_err " The special value 'auto' defaults to 'notice', unless"
|
||||||
print_err " 'DRONE_BUILD_STATUS' indicates a failure."
|
print_err " 'CI_PIPELINE_STATUS'/'DRONE_BUILD_STATUS' indicates a failure."
|
||||||
}
|
}
|
||||||
|
|
||||||
# Blessed Stack Overflow
|
# Blessed Stack Overflow
|
||||||
|
@ -38,6 +38,18 @@ rawurlencode() {
|
||||||
echo "$encoded")
|
echo "$encoded")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default_woodpecker_message() {
|
||||||
|
local msg="Build ${CI_PIPELINE_STATUS}"
|
||||||
|
local woodpecker_url="${CI_SYSTEM_LINK}/${CI_REPO}/${CI_PIPELINE_NUMBER}"
|
||||||
|
if [ "$FORMAT" == "true" ]; then
|
||||||
|
msg="$msg [${CI_REPO}#${CI_COMMIT_SHA:0:8}]($woodpecker_url)"
|
||||||
|
else
|
||||||
|
msg="$msg $woodpecker_url"
|
||||||
|
fi
|
||||||
|
msg="$msg (${CI_COMMIT_TAG:-$CI_COMMIT_BRANCH})"
|
||||||
|
printf '%s' "$msg"
|
||||||
|
}
|
||||||
|
|
||||||
default_drone_message() {
|
default_drone_message() {
|
||||||
local msg="Build ${DRONE_BUILD_STATUS}"
|
local msg="Build ${DRONE_BUILD_STATUS}"
|
||||||
local drone_url="${DRONE_SYSTEM_PROTO}://${DRONE_SYSTEM_HOST}/${DRONE_REPO}/${DRONE_BUILD_NUMBER}"
|
local drone_url="${DRONE_SYSTEM_PROTO}://${DRONE_SYSTEM_HOST}/${DRONE_REPO}/${DRONE_BUILD_NUMBER}"
|
||||||
|
@ -51,7 +63,9 @@ default_drone_message() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ensure_variables() {
|
ensure_variables() {
|
||||||
if [ "$DRONE" == "true" ] && [ -z "$MESSAGE" ]; then
|
if [ "$CI" == "woodpecker" ] && [ -z "$MESSAGE" ]; then
|
||||||
|
MESSAGE="$(default_woodpecker_message)"
|
||||||
|
elif [ "$DRONE" == "true" ] && [ -z "$MESSAGE" ]; then
|
||||||
MESSAGE="$(default_drone_message)"
|
MESSAGE="$(default_drone_message)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -69,7 +83,9 @@ ensure_variables() {
|
||||||
|
|
||||||
get_message_type() {
|
get_message_type() {
|
||||||
if [ "$MSG_TYPE" == "auto" ]; then
|
if [ "$MSG_TYPE" == "auto" ]; then
|
||||||
if [ "$DRONE_BUILD_STATUS" == "failure" ]; then
|
if [ "$CI_PIPELINE_STATUS" == "failure" ]; then
|
||||||
|
MSG_TYPE="text"
|
||||||
|
elif [ "$DRONE_BUILD_STATUS" == "failure" ]; then
|
||||||
MSG_TYPE="text"
|
MSG_TYPE="text"
|
||||||
else
|
else
|
||||||
MSG_TYPE="notice"
|
MSG_TYPE="notice"
|
||||||
|
|
Loading…
Reference in a new issue