-
Notifications
You must be signed in to change notification settings - Fork 18
/
trigger_circle_ci_builds_for_all_packs.sh
executable file
·60 lines (51 loc) · 1.68 KB
/
trigger_circle_ci_builds_for_all_packs.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
55
56
57
58
59
60
#!/usr/bin/env bash
#
# Script which triggers Circle CI builds for all the exchange repos for master
# branch.
#
# Requires: jq
#
# The following env variables must be specified:
# * CIRCLECI_TOKEN: a CircleCI token for the Exchange organization.
# * REPO_NAMES: If specified only force build for specified repo(s) otherwise force it for
# all the repos/
# * FORCE_REBUILD_INDEX: Set it to "1" to force index rebuild.
set -e
# Include script with common functionality
SCRIPT_PATH=$(dirname "$(readlink -f "$0")")
source "${SCRIPT_PATH}/common.sh"
FORCE_REBUILD_INDEX="${FORCE_REBUILD_INDEX:-0}"
if [[ ! ${CIRCLECI_TOKEN} ]]; then
echo "CIRCLECI_TOKEN environment variable not set"
exit 2
fi
if [[ -n "${REPO_NAMES}" ]]; then
# Only force build for provided repos
OIFS=$IFS;
IFS=" "
REPO_NAMES=($REPO_NAMES)
IFS=$OIFS;
else
# Force build for all pack repos
get_all_exchange_repo_names "${EXCHANGE_ORG}" "${EXCHANGE_PREFIX}"
fi
# Trigger Circle CI build for each pack
for REPO_NAME in ${REPO_NAMES[@]}; do
echo "Triggering CircleCI build for repo / pack: ${REPO_NAME}"
CIRCLE_TRIGGER_BUILD_URL="https://circleci.com/api/v1/project/${EXCHANGE_ORG}/${REPO_NAME}/tree/master?circle-token=${CIRCLECI_TOKEN}"
if [[ ${FORCE_REBUILD_INDEX} == "1" ]]; then
curl \
--header "Content-Type: application/json" \
--request POST \
--data '{"build_parameters": {"FORCE_REBUILD_INDEX": "1"}}' \
${CIRCLE_TRIGGER_BUILD_URL}
else
curl \
--header "Content-Type: application/json" \
--request POST \
${CIRCLE_TRIGGER_BUILD_URL}
fi
echo ""
echo "Build page at: "https://circleci.com/gh/${EXCHANGE_ORG}/${REPO_NAME}
sleep ${SLEEP_DELAY}
done