From 22f19a2ced023a09b1aec3ddd0defbae70311da4 Mon Sep 17 00:00:00 2001 From: Jose Date: Fri, 6 Feb 2026 20:54:14 +0100 Subject: [PATCH] Update Jenkinsfile.ci --- Jenkinsfile.ci | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/Jenkinsfile.ci b/Jenkinsfile.ci index b867c70..a075521 100644 --- a/Jenkinsfile.ci +++ b/Jenkinsfile.ci @@ -133,20 +133,26 @@ post { def commentsUrl = "${giteaBase}/gitea/api/v1/repos/${owner}/${repo}/issues/${pr}/comments" withCredentials([usernamePassword(credentialsId: 'jenkins-bot-api', - usernameVariable: 'GITEA_USER', - passwordVariable: 'GITEA_TOKEN')]) { - sh """ - set -e - curl -sS -X POST \ - -H "Authorization: token ${GITEA_TOKEN}" \ - -H "Content-Type: application/json" \ - --data @- \ - '${commentsUrl}' <<'JSON' - {"body":"${msg.replace('\\', '\\\\').replace('"','\\"')}"} - JSON - """ - } + usernameVariable: 'GITEA_USER', + passwordVariable: 'GITEA_TOKEN')]) { + def body = msg.replace('\\', '\\\\').replace('"','\\"').replace('\n','\\n') + + // Avoid interpolation of secret variables (https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#string-interpolation) + withEnv(["GITEA_COMMENTS_URL=${commentsUrl}", "GITEA_BODY=${body}"]) { + sh(label: 'Comentar en PR (Gitea)', script: ''' + set -euo pipefail + + curl -sS -X POST \ + -H "Authorization: token $GITEA_TOKEN" \ + -H "Content-Type: application/json" \ + --data-binary @- \ + "$GITEA_COMMENTS_URL" <