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'
)
]) {
def harborListUrl = "${HARBOR_API}/projects/${params.HARBOR_PROJECT}/repositories?page_size=100"
def services = sh(
script: """
curl -s -u "\${HARBOR_USER}:\${HARBOR_PASS}" \\
--connect-timeout 10 --max-time 30 \\
"${HARBOR_API}/projects/${params.HARBOR_PROJECT}/repositories?page_size=100" \\
| python3 -c "
'${harborListUrl}' \\
| python3 -c '
import sys, json
repos = json.load(sys.stdin)
names = [r['name'].split('/')[-1] for r in repos if isinstance(repos, list)]
print(','.join(sorted(names)))
" 2>/dev/null || echo ""
if not isinstance(repos, list):
sys.exit(1)
names = [r["name"].split("/")[-1] for r in repos]
print(",".join(sorted(names)))
' 2>/dev/null || echo ""
""",
returnStdout: true
).trim()