refactor(woodpecker): streamline Discord payload handling with temporary file usage
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
- Simplified payload preparation by redirecting commit messages to a temporary file. - Ensured cleanup with `rm -f` for improved reliability and maintainability.
This commit is contained in:
@ -20,7 +20,8 @@ steps:
|
||||
|
||||
# Discord Benachrichtigung mit jq (sicher gegen Sonderzeichen)
|
||||
if [ ! -z "$DISCORD_WEBHOOK" ]; then
|
||||
PAYLOAD=$(printf '%s' "${CI_COMMIT_MESSAGE:-No commit message}" | jq -Rs \
|
||||
echo "${CI_COMMIT_MESSAGE:-No commit message}" > /tmp/commit_msg.txt
|
||||
PAYLOAD=$(cat /tmp/commit_msg.txt | jq -Rs \
|
||||
--arg title "⚠️ npm audit Warnung - Build #${CI_BUILD_NUMBER}" \
|
||||
--arg repo "${CI_REPO}" \
|
||||
--arg branch "${CI_COMMIT_BRANCH}" \
|
||||
@ -45,6 +46,7 @@ steps:
|
||||
timestamp: $timestamp
|
||||
}]
|
||||
}')
|
||||
rm -f /tmp/commit_msg.txt
|
||||
|
||||
curl -H "Content-Type: application/json" -X POST \
|
||||
-d "$PAYLOAD" "$DISCORD_WEBHOOK"
|
||||
@ -82,7 +84,8 @@ steps:
|
||||
- apt-get update && apt-get install -y jq
|
||||
- |
|
||||
if [ ! -z "$DISCORD_WEBHOOK" ]; then
|
||||
PAYLOAD=$(printf '%s' "${CI_COMMIT_MESSAGE:-No commit message}" | jq -Rs \
|
||||
echo "${CI_COMMIT_MESSAGE:-No commit message}" > /tmp/commit_msg.txt
|
||||
PAYLOAD=$(cat /tmp/commit_msg.txt | jq -Rs \
|
||||
--arg title "✅ Build #${CI_BUILD_NUMBER} - Success" \
|
||||
--arg repo "${CI_REPO}" \
|
||||
--arg branch "${CI_COMMIT_BRANCH}" \
|
||||
@ -104,6 +107,7 @@ steps:
|
||||
timestamp: $timestamp
|
||||
}]
|
||||
}')
|
||||
rm -f /tmp/commit_msg.txt
|
||||
|
||||
curl -H "Content-Type: application/json" -X POST \
|
||||
-d "$PAYLOAD" "$DISCORD_WEBHOOK"
|
||||
@ -122,7 +126,8 @@ steps:
|
||||
- apt-get update && apt-get install -y jq
|
||||
- |
|
||||
if [ ! -z "$DISCORD_WEBHOOK" ]; then
|
||||
PAYLOAD=$(printf '%s' "${CI_COMMIT_MESSAGE:-No commit message}" | jq -Rs \
|
||||
echo "${CI_COMMIT_MESSAGE:-No commit message}" > /tmp/commit_msg.txt
|
||||
PAYLOAD=$(cat /tmp/commit_msg.txt | jq -Rs \
|
||||
--arg title "❌ Build #${CI_BUILD_NUMBER} - Failure" \
|
||||
--arg repo "${CI_REPO}" \
|
||||
--arg branch "${CI_COMMIT_BRANCH}" \
|
||||
@ -144,6 +149,7 @@ steps:
|
||||
timestamp: $timestamp
|
||||
}]
|
||||
}')
|
||||
rm -f /tmp/commit_msg.txt
|
||||
|
||||
curl -H "Content-Type: application/json" -X POST \
|
||||
-d "$PAYLOAD" "$DISCORD_WEBHOOK"
|
||||
|
||||
Reference in New Issue
Block a user