Skip to content

Commit 2aae0a2

Browse files
committed
_Jenkinsfile-check.sh : manage curl silence/verbosity via optional DEBUG=yes envar; do not spam by default
1 parent 64b4cab commit 2aae0a2

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

_Jenkinsfile-check.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ set -o pipefail
1313
# one is just the simple tool I use as long as it suffices ;)
1414
# See also https://github.com/jenkinsci/pipeline-model-definition-plugin/wiki/Validating-(or-linting)-a-Declarative-Jenkinsfile-from-the-command-line
1515
#
16-
# Copyright (C) 2016-2018 by Jim Klimov
16+
# Copyright (C) 2016-2019 by Jim Klimov
1717

1818
# Components for the URL below; override via ./.jenkinsfile-check in the repo
1919
# (DO NOT git commit this file though!) or in ~/.jenkinsfile-check if you only
@@ -46,12 +46,15 @@ JSONSH=JSON.sh
4646
[ -n "${JENKINSFILE-}" ] && [ -s "${JENKINSFILE}" ] || { echo "FATAL : Did not find a JENKINSFILE='$JENKINSFILE'" >&2 ; exit 1 ; }
4747
[ -n "${JSONSH-}" ] && [ -s "${JSONSH}" ] && [ -x "${JSONSH}" ] || { echo "FATAL : Did not find a JSONSH='$JSONSH' (did you get one from https://github.com/jimklimov/JSON.sh/blob/master/JSON.sh ?)" >&2 ; exit 1 ; }
4848

49+
CURL_VERBOSE="-s"
50+
[ x"${DEBUG-}" = xyes ] && CURL_VERBOSE="-v"
51+
4952
do_request() {
50-
CRUMB="`curl -k -v "$JENKINS_BASEURL/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,%22:%22,//crumb)"`" || CRUMB=""
53+
CRUMB="`curl -k $CURL_VERBOSE "$JENKINS_BASEURL/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,%22:%22,//crumb)"`" || CRUMB=""
5154
echo "$CRUMB" | grep -w 404 >/dev/null && CRUMB=""
5255
[ -n "$CRUMB" ] || echo "NOTE : Did not get a crumb, so will not use one"
5356

54-
curl -k -v ${CRUMB:+H "$CRUMB"} \
57+
curl -k $CURL_VERBOSE ${CRUMB:+H "$CRUMB"} \
5558
-X POST --form "jenkinsfile=<${JENKINSFILE}" \
5659
"$JENKINS_BASEURL/pipeline-model-converter/validateJenkinsfile"
5760
}

0 commit comments

Comments
 (0)