fix(jenkins): quote URL with query params to prevent shell glob expansion

This commit is contained in:
wwweww
2026-05-04 12:19:57 +08:00
parent 4bdd040e91
commit bbccb3e05e
+8 -5
View File
@@ -96,17 +96,20 @@ pipeline {
passwordVariable: 'HARBOR_PASS' passwordVariable: 'HARBOR_PASS'
) )
]) { ]) {
def harborListUrl = "${HARBOR_API}/projects/${params.HARBOR_PROJECT}/repositories?page_size=100"
def services = sh( def services = sh(
script: """ script: """
curl -s -u "\${HARBOR_USER}:\${HARBOR_PASS}" \\ curl -s -u "\${HARBOR_USER}:\${HARBOR_PASS}" \\
--connect-timeout 10 --max-time 30 \\ --connect-timeout 10 --max-time 30 \\
"${HARBOR_API}/projects/${params.HARBOR_PROJECT}/repositories?page_size=100" \\ '${harborListUrl}' \\
| python3 -c " | python3 -c '
import sys, json import sys, json
repos = json.load(sys.stdin) repos = json.load(sys.stdin)
names = [r['name'].split('/')[-1] for r in repos if isinstance(repos, list)] if not isinstance(repos, list):
print(','.join(sorted(names))) sys.exit(1)
" 2>/dev/null || echo "" names = [r["name"].split("/")[-1] for r in repos]
print(",".join(sorted(names)))
' 2>/dev/null || echo ""
""", """,
returnStdout: true returnStdout: true
).trim() ).trim()