Skip to content

Commit cdc4b4e

Browse files
Url encode build url in Bitbucket comment
1 parent 812bc88 commit cdc4b4e

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

assets/helpers/bitbucket.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ bitbucket_pullrequest_progress_comment() {
123123
# $2: hash of merge commit
124124
# $3: hash of source commit
125125
# $4: hash of target commit
126-
build_url="$ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME"
126+
build_url="$ATC_EXTERNAL_URL/teams/$(rawurlencode $BUILD_TEAM_NAME)/pipelines/$(rawurlencode $BUILD_PIPELINE_NAME)/jobs/$(rawurlencode $BUILD_JOB_NAME)/builds/$(rawurlencode $BUILD_NAME)"
127127
build_status_pre="[*Build"
128128
build_status_post="* **${BUILD_PIPELINE_NAME}-${BUILD_JOB_NAME}** for $2"
129129
if [ "$2" == "$3" ]; then

assets/helpers/utils.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,22 @@ date_from_epoch_seconds() {
123123
#date -r $1
124124
date -d @$1
125125
}
126+
127+
# http://stackoverflow.com/questions/296536/how-to-urlencode-data-for-curl-command
128+
rawurlencode() {
129+
local string="${1}"
130+
local strlen=${#string}
131+
local encoded=""
132+
local pos c o
133+
134+
for (( pos=0 ; pos<strlen ; pos++ )); do
135+
c=${string:$pos:1}
136+
case "$c" in
137+
[-_.~a-zA-Z0-9] ) o="${c}" ;;
138+
* ) printf -v o '%%%02x' "'$c"
139+
esac
140+
encoded+="${o}"
141+
done
142+
143+
echo "${encoded}"
144+
}

0 commit comments

Comments
 (0)