mirror of
https://github.com/SonarSource/sonarqube-quality-gate-action.git
synced 2026-09-23 13:38:32 +00:00
* feat(SQQGGHA-12): surface SonarQube error message on background task failure Report the analysis error message when the background task status is not SUCCESS, instead of only failing at the quality gate lookup step. * fix: surface CANCELED SonarQube task status with clear message Co-authored-by: Amaury Wyart <285676107+amaurywyart-sq@users.noreply.github.com> * fix: use octal ANSI escape codes for bash 3.2 compatibility \e is not interpreted by echo -e on bash 3.2 (e.g. macOS/self-hosted runners), which printed raw escape sequences instead of colored output. \033 works on both bash 3.2 and modern bash. --------- Co-authored-by: Gitar <noreply@gitar.ai> Co-authored-by: Amaury Wyart <285676107+amaurywyart-sq@users.noreply.github.com>
59 lines
1.2 KiB
Bash
Executable File
59 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Begin Standard 'imports'
|
|
set -e
|
|
set -o pipefail
|
|
|
|
gray="\\033[37m"
|
|
blue="\\033[36m"
|
|
red="\\033[31m"
|
|
yellow="\\033[33m"
|
|
green="\\033[32m"
|
|
reset="\\033[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; }
|
|
|
|
# support old GH Actions runners
|
|
set_output () {
|
|
if [[ -n "${GITHUB_OUTPUT}" ]]; then
|
|
echo "${1}=${2}" >> "${GITHUB_OUTPUT}"
|
|
else
|
|
echo "::set-output name=${1}::${2}"
|
|
fi
|
|
}
|
|
|
|
## 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'
|
|
|