From c1fd535549d4295e28acc0de1f0ad221f321df59 Mon Sep 17 00:00:00 2001 From: Kenzo Date: Wed, 7 Jan 2026 16:34:25 +0100 Subject: [PATCH] refactor(woodpecker): streamline Discord payload handling with temporary file usage - Simplified payload preparation by redirecting commit messages to a temporary file. - Ensured cleanup with `rm -f` for improved reliability and maintainability. --- .woodpecker.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index d54a31b..5a87a4d 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -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"