fix(jenkins): quote URL with query params to prevent shell glob expansion
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user