-
Notifications
You must be signed in to change notification settings - Fork 194
/
.gitlab-ci.yml
55 lines (51 loc) · 2.28 KB
/
.gitlab-ci.yml
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
stages:
- Build
Build-Image:
tags:
- rhel_builder
stage: Build
script:
- if [ "$DOCKER_NAMESPACE" == "" ]; then DOCKER_NAMESPACE="local"; fi
- export BASE_PUSH_TARGET="$CI_REGISTRY/$DOCKER_NAMESPACE/k8s-bigip-ctlr"
- |
if [ "$CI_REGISTRY_PASSWORD" == "" -o "$CI_REGISTRY_USER" == "" -o $DOCKER_NAMESPACE == "" -o $CI_REGISTRY == "" ]; then
echo "[INFO] Docker registry, user, password, or namespace vars absent from Gitlab environment variable."
echo "[INFO] See README.md section 'build' to configure travis with DockerHub."
else
docker login $CI_REGISTRY -u="$CI_REGISTRY_USER" -p="$CI_REGISTRY_PASSWORD"
DOCKER_READY="true"
fi
- export BUILD_VERSION=$(build-tools/version-tool version)
- export BUILD_INFO=$(build-tools/version-tool build-info)
- if [ "$CI_COMMIT_TAG" == "$CI_COMMIT_REF_NAME" ]; then BUILD_VERSION=$CI_COMMIT_TAG; fi
- export IMG_TAG="${BASE_PUSH_TARGET}:${CI_COMMIT_SHA}"
- export BUILD_IMG_TAG="${BASE_PUSH_TARGET}-devel:${CI_COMMIT_SHA}"
- export BUILD_STAMP=devel-$CI_COMMIT_REF_NAME-n-$CI_CONCURRENT_PROJECT_ID-id-$CI_CONCURRENT_ID-$(date +%s)
- export USER=$(whoami)
- |
if echo "$CI_COMMIT_REF_NAME" | grep -Eq "\-stable"; then
export CTLR_VERSION=v$(echo $CI_COMMIT_REF_NAME | sed s/-stable//g)
export LICENSE_STRICT=false
elif echo "$CI_COMMIT_REF_NAME" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]*' ; then
export CTLR_VERSION=$(echo "$CI_COMMIT_REF_NAME" | awk -F'.' '{print $1"."$2}')
export LICENSE_STRICT=true
else
export CTLR_VERSION=$CI_COMMIT_REF_NAME
export LICENSE_STRICT=false
fi
- export CLEAN_BUILD=true
- export BASE_OS=rhel7
- make prod
- echo "export BUILD_IMG_TAG=$BUILD_IMG_TAG;" >> shared-vars.sh
- |
if [ "$DOCKER_READY" ]; then
docker push $IMG_TAG
docker tag "$IMG_TAG" "$BASE_PUSH_TARGET"
docker push "$BASE_PUSH_TARGET:latest"
docker tag "$IMG_TAG" "$BASE_PUSH_TARGET:$BUILD_STAMP"
docker push "$BASE_PUSH_TARGET:$BUILD_STAMP"
docker tag "$IMG_TAG" "$BASE_PUSH_TARGET:$BUILD_VERSION"
docker push "$BASE_PUSH_TARGET:$BUILD_VERSION"
docker tag "$IMG_TAG" "$BUILD_IMG_TAG"
docker push "$BUILD_IMG_TAG"
fi