Fix slack escaping (#8311)

The previous escaping syntax doesn’t seem to work (after the first
layer you no longer have a variable) and has broken our build
reporting completely.

changelog_begin
changelog_end
This commit is contained in:
Moritz Kiefer 2020-12-16 12:18:41 +01:00 committed by GitHub
parent 1f048af9d8
commit fbf1820f94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 4 deletions

View File

@ -9,6 +9,14 @@ steps:
set -euo pipefail set -euo pipefail
TMP=$(mktemp) TMP=$(mktemp)
cat > $TMP <<'END' cat > $TMP <<'END'
escape_slack() {
local r
r="$1"
r="${r//&/&amp;}"
r="${r//>/&gt;}"
r="${r//</&lt;}"
echo "$r"
}
get_gh_auth_header() { get_gh_auth_header() {
# Credentials are persisted in a different way on GCP and Azure nodes. # Credentials are persisted in a different way on GCP and Azure nodes.
if header=$(git config 'http.https://github.com/digital-asset/daml.extraheader'); then if header=$(git config 'http.https://github.com/digital-asset/daml.extraheader'); then

View File

@ -5,11 +5,15 @@ parameters:
success-message: '\"$(Agent.JobName) passed: $COMMIT_LINK\"' success-message: '\"$(Agent.JobName) passed: $COMMIT_LINK\"'
steps: steps:
- template: bash-lib.yml
parameters:
var_name: bash_lib
- bash: | - bash: |
set -euo pipefail set -euo pipefail
eval "$(dev-env/bin/dade assist)" eval "$(dev-env/bin/dade assist)"
COMMIT_TITLE=$(git log --pretty=format:%s -n1) source $(bash_lib)
COMMIT_LINK="<https://dev.azure.com/digitalasset/daml/_build/results?buildId=$(Build.BuildId)|${${${COMMIT_TITLE//&/&amp;}//>/&gt;}//</&lt;}>" COMMIT_TITLE="$(escape_slack $(git log --pretty=format:%s -n1 ${{ parameters.trigger_sha }}))"
COMMIT_LINK="<https://dev.azure.com/digitalasset/daml/_build/results?buildId=$(Build.BuildId)|${COMMIT_TITLE}>"
if [ "$(Agent.JobStatus)" != "Succeeded" ]; then if [ "$(Agent.JobStatus)" != "Succeeded" ]; then
MESSAGE="\":fire: :fire: <!here> :fire: :fire:\n$(Agent.JobName) *FAILED*: $COMMIT_LINK\n:fire: :fire:\"" MESSAGE="\":fire: :fire: <!here> :fire: :fire:\n$(Agent.JobName) *FAILED*: $COMMIT_LINK\n:fire: :fire:\""
else else

View File

@ -5,10 +5,14 @@ parameters:
trigger_sha: '' trigger_sha: ''
steps: steps:
- template: bash-lib.yml
parameters:
var_name: bash_lib
- bash: | - bash: |
set -euo pipefail set -euo pipefail
COMMIT_TITLE=$(git log --pretty=format:%s -n1 ${{ parameters.trigger_sha }}) source $(bash_lib)
COMMIT_LINK="<https://dev.azure.com/digitalasset/daml/_build/results?buildId=$(Build.BuildId)|${${${COMMIT_TITLE//&/&amp;}//>/&gt;}//</&lt;}>" COMMIT_TITLE="$(escape_slack $(git log --pretty=format:%s -n1 ${{ parameters.trigger_sha }}))"
COMMIT_LINK="<https://dev.azure.com/digitalasset/daml/_build/results?buildId=$(Build.BuildId)|${COMMIT_TITLE}>"
if [ -z "${{ parameters.trigger_sha }}" ]; then if [ -z "${{ parameters.trigger_sha }}" ]; then
WARNING="<!here> *FAILED* $(Build.SourceBranchName)/$(Agent.JobName): $COMMIT_LINK" WARNING="<!here> *FAILED* $(Build.SourceBranchName)/$(Agent.JobName): $COMMIT_LINK"
else else