-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrigger-travis-ci-build-via-rest-api.sh
54 lines (47 loc) · 1.35 KB
/
trigger-travis-ci-build-via-rest-api.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
48
49
50
51
52
53
54
#!/usr/bin/env bash
# https://travis-ci.org/ajurge/cubes --> More Options --> Trigger Build
#env:
# global:
# - PERFORM_RELEASE=release
# - RELEASE_VERSION="<MAJOR.MINOR.PATCH>"
# - DEVELOPMENT_VERSION="<MAJOR.MINOR.PATCH>"
# - CLOSE_SONATYPE_STAGING="1"
if [ -z "$1" ]
then
echo "No release version supplied"
exit 1
fi
if [ -z "$2" ]
then
echo "No development version supplied"
exit 1
fi
RELEASE_VERSION=$1
DEVELOPMENT_VERSION=$2
TRAVIS_CI_BUILD_REST_API_URL=https://api.travis-ci.org/repo/ajurge%2Fcubes/requests
if [ -z "$API_TOKEN" ]
then
echo "Enter Travis CI API token for $TRAVIS_CI_BUILD_REST_API_URL:"
read -t 10 -s API_TOKEN || { echo "Error: Travis CI API token not supplied"; exit 1; }
fi
BODY='{
"request": {
"message": "Triggered via REST API: Release version '"$RELEASE_VERSION"' and set next development cycle version to '"$DEVELOPMENT_VERSION"'",
"config": {
"env": {
"global": {
"PERFORM_RELEASE": "release",
"RELEASE_VERSION": "'"$RELEASE_VERSION"'",
"DEVELOPMENT_VERSION": "'"$DEVELOPMENT_VERSION"'",
"CLOSE_SONATYPE_STAGING": "1"
}
}
}
}}'
curl -s -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Travis-API-Version: 3" \
-H "Authorization: token $API_TOKEN" \
-d "$BODY" \
"$TRAVIS_CI_BUILD_REST_API_URL"