diff --git a/ci/bash-lib.yml b/ci/bash-lib.yml index c8ea7baa2b..52d3cb1e7c 100644 --- a/ci/bash-lib.yml +++ b/ci/bash-lib.yml @@ -9,6 +9,14 @@ steps: set -euo pipefail TMP=$(mktemp) cat > $TMP <<'END' + escape_slack() { + local r + r="$1" + r="${r//&/&}" + r="${r//>/>}" + r="${r///>}//" + source $(bash_lib) + COMMIT_TITLE="$(escape_slack $(git log --pretty=format:%s -n1 ${{ parameters.trigger_sha }}))" + COMMIT_LINK="" if [ "$(Agent.JobStatus)" != "Succeeded" ]; then MESSAGE="\":fire: :fire: :fire: :fire:\n$(Agent.JobName) *FAILED*: $COMMIT_LINK\n:fire: :fire:\"" else diff --git a/ci/tell-slack-failed.yml b/ci/tell-slack-failed.yml index 2795f4ef45..7c84d935d7 100644 --- a/ci/tell-slack-failed.yml +++ b/ci/tell-slack-failed.yml @@ -5,10 +5,14 @@ parameters: trigger_sha: '' steps: + - template: bash-lib.yml + parameters: + var_name: bash_lib - bash: | set -euo pipefail - COMMIT_TITLE=$(git log --pretty=format:%s -n1 ${{ parameters.trigger_sha }}) - COMMIT_LINK="/>}//" + source $(bash_lib) + COMMIT_TITLE="$(escape_slack $(git log --pretty=format:%s -n1 ${{ parameters.trigger_sha }}))" + COMMIT_LINK="" if [ -z "${{ parameters.trigger_sha }}" ]; then WARNING=" *FAILED* $(Build.SourceBranchName)/$(Agent.JobName): $COMMIT_LINK" else