dotfiles/dot_scripts/checkci.sh

34 lines
907 B
Bash
Raw Normal View History

#!/usr/bin/env bash
###
### checkci — checks a Jenkinsfile syntax against a real Jenkins instance
###
### Note: this script gets:
### the (jenkins) username from git config
### the (jenkins) password/secret from Environment variable $JENKINS_SECRET
### the (jenkins) URL from Environment variable $JENKINS_URL
###
### Usage:
### checkci.sh [jenkinsfile]
###
### Options:
### [input] path to Jenkinsfile (optional).
### -h Show this message.
help() {
gsed -rn 's/^### ?//;T;p' "$0"
}
if [[ $# == 0 ]] || [[ "$1" == "-h" ]]; then
help
exit 1
fi
function _checkci() {
local username
2020-07-18 14:55:52 +00:00
username="$(git config --global -l G "user.email" | cut -d'@' -f1 | cut -d'=' -f2)"
local jenkinsfile="${1:-Jenkinsfile}"
curl --user "$username:$JENKINS_SECRET" -X POST -F "jenkinsfile=<$jenkinsfile" "$JENKINS_URL/pipeline-model-converter/validate"
}
_checkci "$*"
exit 0