fix: Jenkins crumb 파싱에 python3 사용 (node 미설치 환경)
post-receive hook PATH에 node가 없어 트리거가 실패하던 문제를 수정한다. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -56,11 +56,18 @@ if curl_get "${JOB_API}/lastBuild/api/json?tree=building" 2>/dev/null | grep -q
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
parse_crumb_field() {
|
||||||
|
python3 -c "import sys,json; print(json.load(sys.stdin).get('crumbRequestField',''))" 2>/dev/null || true
|
||||||
|
}
|
||||||
|
parse_crumb_val() {
|
||||||
|
python3 -c "import sys,json; print(json.load(sys.stdin).get('crumb',''))" 2>/dev/null || true
|
||||||
|
}
|
||||||
|
|
||||||
CRUMB_HDR=()
|
CRUMB_HDR=()
|
||||||
CRUMB_JSON="$(curl_get "${JENKINS_URL}/crumbIssuer/api/json" 2>/dev/null || true)"
|
CRUMB_JSON="$(curl_get "${JENKINS_URL}/crumbIssuer/api/json" 2>/dev/null || true)"
|
||||||
if [[ -n "$CRUMB_JSON" ]]; then
|
if [[ -n "$CRUMB_JSON" ]]; then
|
||||||
FIELD="$(node -e "try{console.log(JSON.parse(process.argv[1]).crumbRequestField||'')}catch{}" "$CRUMB_JSON" 2>/dev/null || true)"
|
FIELD="$(printf '%s' "$CRUMB_JSON" | parse_crumb_field)"
|
||||||
VAL="$(node -e "try{console.log(JSON.parse(process.argv[1]).crumb||'')}catch{}" "$CRUMB_JSON" 2>/dev/null || true)"
|
VAL="$(printf '%s' "$CRUMB_JSON" | parse_crumb_val)"
|
||||||
if [[ -n "$FIELD" && -n "$VAL" ]]; then
|
if [[ -n "$FIELD" && -n "$VAL" ]]; then
|
||||||
CRUMB_HDR=(-H "${FIELD}: ${VAL}")
|
CRUMB_HDR=(-H "${FIELD}: ${VAL}")
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -56,11 +56,18 @@ if curl_get "${JOB_API}/lastBuild/api/json?tree=building" 2>/dev/null | grep -q
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
parse_crumb_field() {
|
||||||
|
python3 -c "import sys,json; print(json.load(sys.stdin).get('crumbRequestField',''))" 2>/dev/null || true
|
||||||
|
}
|
||||||
|
parse_crumb_val() {
|
||||||
|
python3 -c "import sys,json; print(json.load(sys.stdin).get('crumb',''))" 2>/dev/null || true
|
||||||
|
}
|
||||||
|
|
||||||
CRUMB_HDR=()
|
CRUMB_HDR=()
|
||||||
CRUMB_JSON="$(curl_get "${JENKINS_URL}/crumbIssuer/api/json" 2>/dev/null || true)"
|
CRUMB_JSON="$(curl_get "${JENKINS_URL}/crumbIssuer/api/json" 2>/dev/null || true)"
|
||||||
if [[ -n "$CRUMB_JSON" ]]; then
|
if [[ -n "$CRUMB_JSON" ]]; then
|
||||||
FIELD="$(node -e "try{console.log(JSON.parse(process.argv[1]).crumbRequestField||'')}catch{}" "$CRUMB_JSON" 2>/dev/null || true)"
|
FIELD="$(printf '%s' "$CRUMB_JSON" | parse_crumb_field)"
|
||||||
VAL="$(node -e "try{console.log(JSON.parse(process.argv[1]).crumb||'')}catch{}" "$CRUMB_JSON" 2>/dev/null || true)"
|
VAL="$(printf '%s' "$CRUMB_JSON" | parse_crumb_val)"
|
||||||
if [[ -n "$FIELD" && -n "$VAL" ]]; then
|
if [[ -n "$FIELD" && -n "$VAL" ]]; then
|
||||||
CRUMB_HDR=(-H "${FIELD}: ${VAL}")
|
CRUMB_HDR=(-H "${FIELD}: ${VAL}")
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user