|
1 | 1 | #!/bin/bash -x |
2 | 2 |
|
| 3 | +_dir=$(readlink -e "$(dirname "$0")") |
| 4 | +# refactored a few functions into single file scripts for easier development/debugging, see ENT-12741 and ENT-12595 |
| 5 | +# Easier to add a path to a script than source a file of functions. |
| 6 | +export PATH="$_dir"/bin:$PATH |
3 | 7 | . `dirname "$0"`/functions |
4 | 8 | . detect-environment |
5 | 9 | . compile-options |
6 | 10 | . version |
7 | 11 |
|
8 | | -get_GH_PR_info() { |
9 | | - # Args: |
10 | | - # $1 - repo identifier ("project/repo") |
11 | | - # $2 - PR identifier (the PR number) |
12 | | - # Env: |
13 | | - # $GITHUB_STATUS_TOKEN - token for GitHub authentication |
14 | | - # Prints: |
15 | | - # $REPO_ID $PR_ID $PR_STATUSES_URL |
16 | | - # Where: |
17 | | - # $PR_STATUSES_URL - GH API URL to set PR's statuses |
18 | | - # Returns: |
19 | | - # 0 - success, 1 - error |
20 | | - if [ -z "$1" ] || [ -z "$2" ] || [ -z "$GITHUB_STATUS_TOKEN" ]; then return 1; fi |
21 | | - |
22 | | - if which jq > /dev/null; then |
23 | | - URL=$(curl -k -H "Authorization: token $GITHUB_STATUS_TOKEN" https://api.github.com/repos/$1/pulls/$2 | |
24 | | - jq ".statuses_url" | tr -d '"') |
25 | | - status=$? |
26 | | - else |
27 | | - URL=$(curl -k -H "Authorization: token $GITHUB_STATUS_TOKEN" https://api.github.com/repos/$1/pulls/$2 | |
28 | | - grep "statuses_url" | head -n1 | sed -r 's/\s+"statuses_url": "([^"]+)",/\1/') |
29 | | - status=$? |
30 | | - fi |
31 | | - |
32 | | - echo "$1 $2 $URL" |
33 | | - return $status |
34 | | -} |
| 12 | +mkdir -p $BASEDIR/output/tarballs |
35 | 13 |
|
| 14 | +# the first part of the script is not really critical |
| 15 | +set +e |
36 | 16 |
|
37 | | -mkdir -p $BASEDIR/output/tarballs |
| 17 | +# Get information about PRs among the used revisions. |
| 18 | +# These PRs will have to be notified of build progress. |
| 19 | +for repo_spec in cfengine/buildscripts cfengine/core cfengine/masterfiles cfengine/enterprise cfengine/nova cfengine/mission-portal NorthernTechHQ/libntech; do |
| 20 | + # remove organization/ from start of repo_spec |
| 21 | + repo="${repo_spec#*/}" |
| 22 | + rev_param_name="$(echo $repo | tr '[:lower:]-' '[:upper:]_')_REV" |
| 23 | + revision="$(echo ${!rev_param_name})" || continue # dereference |
| 24 | + |
| 25 | + # remove "origin/" (if any) |
| 26 | + revision="${revision##origin/}" |
| 27 | + if expr "$revision" : "pull/" >/dev/null; then |
| 28 | + pr_nr="$(echo $revision | cut -d/ -f2)" |
| 29 | + get-github-pull-request-info "$repo_spec" "$pr_nr" >> $BASEDIR/output/PRs |
| 30 | + fi |
| 31 | +done |
| 32 | + |
| 33 | +# now script failures should fail the script |
| 34 | +set -e |
38 | 35 |
|
39 | 36 | cd $BASEDIR/core |
40 | 37 | rm cfengine-3.*.tar.gz || true |
@@ -109,20 +106,3 @@ if test -f "$BASEDIR/mission-portal/ldap/composer.json"; then |
109 | 106 | fi |
110 | 107 | ) |
111 | 108 |
|
112 | | -# the rest of the script is not really critical |
113 | | -set +e |
114 | | - |
115 | | -# Get information about PRs among the used revisions. |
116 | | -# These PRs will have to be notified of build progress. |
117 | | -for repo in buildscripts core masterfiles enterprise nova mission-portal; do |
118 | | - rev_param_name="$(echo $repo | tr '[:lower:]-' '[:upper:]_')_REV" |
119 | | - revision="$(echo ${!rev_param_name})" || continue # dereference |
120 | | - |
121 | | - # remove "origin/" (if any) |
122 | | - revision="${revision##origin/}" |
123 | | - if expr "$revision" : "pull/" >/dev/null; then |
124 | | - repo_spec="cfengine/$repo" |
125 | | - pr_nr="$(echo $revision | cut -d/ -f2)" |
126 | | - get_GH_PR_info "$repo_spec" "$pr_nr" >> $BASEDIR/output/PRs |
127 | | - fi |
128 | | -done |
0 commit comments