forked from jlongtine/aws-codebuild-extras
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·53 lines (46 loc) · 2.58 KB
/
install
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
#!/bin/sh
export CI=true
export CODEBUILD=true
echo "==> CODEBUILD_SOURCE_VERSION = $CODEBUILD_SOURCE_VERSION"
export CODEBUILD_GIT_BRANCHES="$(git branch -r --points-at HEAD --sort='*authordate' | sed 's|origin/||g' | sed 's|[[:blank:]]||g')";
echo "CODEBUILD_GIT_BRANCHES: $CODEBUILD_GIT_BRANCHES";
FILTERED_BRANCHES="$(echo "$CODEBUILD_GIT_BRANCHES" | grep $CODEBUILD_SOURCE_VERSION)";
echo "FILTERED_BRANCHES: $FILTERED_BRANCHES";
if [ "$FILTERED_BRANCHES" != "" ]; then
POSSIBLE_BRANCHES="$FILTERED_BRANCHES";
else
POSSIBLE_BRANCHES="$CODEBUILD_GIT_BRANCHES";
fi
echo "POSSIBLE_BRANCHES: $POSSIBLE_BRANCHES";
export CODEBUILD_GIT_BRANCH="$(echo "$POSSIBLE_BRANCHES" | head -n1)";
export CODEBUILD_GIT_CLEAN_BRANCH="$(echo "$CODEBUILD_GIT_BRANCH" | tr '/' '.')";
export CODEBUILD_GIT_CLEAN_BRANCHES="$(echo "$CODEBUILD_GIT_BRANCHES" | tr '/' '.')";
export CODEBUILD_GIT_MESSAGE="$(git log -1 --pretty=%B)"
export CODEBUILD_GIT_AUTHOR="$(git log -1 --pretty=%an)"
export CODEBUILD_GIT_AUTHOR_EMAIL="$(git log -1 --pretty=%ae)"
export CODEBUILD_GIT_COMMIT="$(git log -1 --pretty=%H)"
export CODEBUILD_GIT_SHORT_COMMIT="$(git log -1 --pretty=%h)"
export CODEBUILD_GIT_TAG="$(git describe --tags --exact-match 2>/dev/null)"
export CODEBUILD_GIT_TIMESTAMP="$(TZ=UTC git show --quiet --date='format-local:%Y%m%d.%H%M%SZ' --format="%cd")"
export CODEBUILD_PULL_REQUEST=false
if [ "${CODEBUILD_SOURCE_VERSION#pr/}" != "$CODEBUILD_SOURCE_VERSION" ] ; then
export CODEBUILD_PULL_REQUEST=${CODEBUILD_SOURCE_VERSION#pr/};
fi
export CODEBUILD_PROJECT=${CODEBUILD_BUILD_ID%:$CODEBUILD_LOG_PATH}
export CODEBUILD_BUILD_URL=https://$AWS_DEFAULT_REGION.console.aws.amazon.com/codebuild/home?region=$AWS_DEFAULT_REGION#/builds/$CODEBUILD_BUILD_ID/view/new
echo "==> AWS CodeBuild Extra Environment Variables:"
echo "==> CI = $CI"
echo "==> CODEBUILD = $CODEBUILD"
echo "==> CODEBUILD_GIT_AUTHOR = $CODEBUILD_GIT_AUTHOR"
echo "==> CODEBUILD_GIT_AUTHOR_EMAIL = $CODEBUILD_GIT_AUTHOR_EMAIL"
echo "==> CODEBUILD_GIT_BRANCH = $CODEBUILD_GIT_BRANCH"
echo "==> CODEBUILD_GIT_CLEAN_BRANCH = $CODEBUILD_GIT_CLEAN_BRANCH"
echo "==> CODEBUILD_GIT_BRANCHES = $CODEBUILD_GIT_BRANCHES"
echo "==> CODEBUILD_GIT_CLEAN_BRANCHES = $CODEBUILD_GIT_CLEAN_BRANCHES"
echo "==> CODEBUILD_GIT_COMMIT = $CODEBUILD_GIT_COMMIT"
echo "==> CODEBUILD_GIT_SHORT_COMMIT = $CODEBUILD_GIT_SHORT_COMMIT"
echo "==> CODEBUILD_GIT_MESSAGE = $CODEBUILD_GIT_MESSAGE"
echo "==> CODEBUILD_GIT_TAG = $CODEBUILD_GIT_TAG"
echo "==> CODEBUILD_GIT_TIMESTAMP = $CODEBUILD_GIT_TIMESTAMP"
echo "==> CODEBUILD_PROJECT = $CODEBUILD_PROJECT"
echo "==> CODEBUILD_PULL_REQUEST = $CODEBUILD_PULL_REQUEST"