-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathstep.sh
47 lines (38 loc) · 1.08 KB
/
step.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
set -ex
echo "${devops_commit_state} ${devops_description}"
state=$devops_commit_state
description=$devops_description
if [ $state == "auto" ]
then
state="failed"
if [ $BITRISE_BUILD_STATUS -eq 0 ]
then
state="succeeded"
fi
fi
if [ -z "$description" ]
then
description="${BITRISE_APP_TITLE} build #${BITRISE_BUILD_NUMBER} ${state}"
fi
URL="https://${devops_user}:${devops_pat}@dev.azure.com/${devops_organization}/${devops_project}/_apis/git/repositories/${devops_repository_id}/commits/${BITRISE_GIT_COMMIT}/statuses?api-version=5.1"
HTTP_RESPONSE=$(curl $URL --silent --write-out "HTTPSTATUS:%{http_code}" \
-H "Content-Type: application/json" \
-d @- <<EOF
{
"state": "${state}",
"description": "${description}",
"targetUrl": "${devops_target_url}",
"context": {
"name": "${devops_context_name}",
"genre": "${devops_context_genre}"
}
}
EOF
)
HTTP_STATUS=$(echo $HTTP_RESPONSE | tr -d '\n' | sed -E 's/.*HTTPSTATUS:([0-9]{3})$/\1/')
if [ ! $HTTP_STATUS -eq 201 ]
then
echo "Error [HTTP status: $HTTP_STATUS]"
exit 1
fi