From b0b0fcb682909ea14f47a606b13b6f913fa4adcd Mon Sep 17 00:00:00 2001 From: Macbook Date: Sun, 14 Jun 2026 12:00:11 +0900 Subject: [PATCH] fix: Jenkins desktop trigger when CSRF crumb is absent (bash set -u) Co-authored-by: Cursor --- scripts/trigger-desktop-jenkins-build.sh | 29 +++++++++++++++++------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/scripts/trigger-desktop-jenkins-build.sh b/scripts/trigger-desktop-jenkins-build.sh index 5c7083f..f31d7f5 100755 --- a/scripts/trigger-desktop-jenkins-build.sh +++ b/scripts/trigger-desktop-jenkins-build.sh @@ -52,15 +52,28 @@ if [[ -n "$CRUMB_JSON" ]]; then fi fi -if curl_post "${CRUMB_HDR[@]}" -H "Content-Type: application/x-www-form-urlencoded" \ - "${JOB_API}/build?token=${JENKINS_TRIGGER_TOKEN}"; then - log "빌드 큐 등록 완료 (token)" - exit 0 -fi +if ((${#CRUMB_HDR[@]})); then + if curl_post "${CRUMB_HDR[@]}" -H "Content-Type: application/x-www-form-urlencoded" \ + "${JOB_API}/build?token=${JENKINS_TRIGGER_TOKEN}"; then + log "빌드 큐 등록 완료 (token)" + exit 0 + fi -if curl_post "${CRUMB_HDR[@]}" -H "Content-Type: application/x-www-form-urlencoded" "${JOB_API}/build"; then - log "빌드 큐 등록 완료" - exit 0 + if curl_post "${CRUMB_HDR[@]}" -H "Content-Type: application/x-www-form-urlencoded" "${JOB_API}/build"; then + log "빌드 큐 등록 완료" + exit 0 + fi +else + if curl_post -H "Content-Type: application/x-www-form-urlencoded" \ + "${JOB_API}/build?token=${JENKINS_TRIGGER_TOKEN}"; then + log "빌드 큐 등록 완료 (token)" + exit 0 + fi + + if curl_post -H "Content-Type: application/x-www-form-urlencoded" "${JOB_API}/build"; then + log "빌드 큐 등록 완료" + exit 0 + fi fi log "[ERROR] Jenkins build trigger failed"