dotfiles/dot_scripts/checkci.sh
MorganGeek 3a3fc30b8c fix technical debt + fine tune functions and hooks
- linting/fixing/formating
- utility for suggesting aliases now accepts parameters to change output
  size
- add helper to checkci
- add verify committer script to avoid committer with wrong git identify
2020-07-12 16:22:17 +02:00

34 lines
912 B
Bash
Executable File

#!/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
username="$(git config --global -l | grep "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