mirror of
https://github.com/SonarSource/sonarqube-quality-gate-action.git
synced 2026-09-23 13:38:32 +00:00
50 lines
987 B
Bash
Executable File
50 lines
987 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Begin Standard 'imports'
|
|
set -e
|
|
set -o pipefail
|
|
|
|
gray="\\e[37m"
|
|
blue="\\e[36m"
|
|
red="\\e[31m"
|
|
yellow="\\e[33m"
|
|
green="\\e[32m"
|
|
reset="\\e[0m"
|
|
|
|
info() { echo -e "${blue}INFO: $*${reset}"; }
|
|
error() { echo -e "${red}ERROR: $*${reset}"; }
|
|
debug() {
|
|
if [[ "${DEBUG}" == "true" ]]; then
|
|
echo -e "${gray}DEBUG: $*${reset}";
|
|
fi
|
|
}
|
|
|
|
success() { echo -e "${green}✔ $*${reset}"; }
|
|
warn() { echo -e "${yellow}✖ $*${reset}"; exit 1; }
|
|
fail() { echo -e "${red}✖ $*${reset}"; exit 1; }
|
|
|
|
## Enable debug mode.
|
|
enable_debug() {
|
|
if [[ "${DEBUG}" == "true" ]]; then
|
|
info "Enabling debug mode."
|
|
set -x
|
|
fi
|
|
}
|
|
|
|
# Execute a command, saving its output and exit status code, and echoing its output upon completion.
|
|
# Globals set:
|
|
# status: Exit status of the command that was executed.
|
|
# output: Output generated from the command.
|
|
#
|
|
run() {
|
|
echo "$@"
|
|
set +e
|
|
output=$("$@" 2>&1)
|
|
status=$?
|
|
set -e
|
|
echo "${output}"
|
|
}
|
|
|
|
# End standard 'imports'
|
|
|