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'
|
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()
|
||||||
|
|||||||
Reference in New Issue
Block a user