forked from F5Networks/k8s-bigip-ctlr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
125 lines (117 loc) · 5.37 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
stages:
- Build
- Test
Build-Image:
tags:
- docker-executor
stage: Build
image: docker
artifacts:
paths:
- shared-vars.sh
script:
- apk update
- apk add git make python coreutils bash sudo
- if [ "$DOCKER_NAMESPACE" == "" ]; then DOCKER_NAMESPACE="local"; fi
- export BASE_PUSH_TARGET="$DOCKER_NAMESPACE/k8s-bigip-ctlr"
- |
if [ "$CI_REGISTRY_PASSWORD" == "" -o "$CI_REGISTRY_USER" == "" -o $DOCKER_NAMESPACE == "" ]; then
echo "[INFO] Docker user, password, or namespace vars absent from travis-ci."
echo "[INFO] See README.md section 'build' to configure travis with DockerHub."
else
docker login -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=debian
- make prod
- echo "export BUILD_IMG_TAG=$BUILD_IMG_TAG;" >> shared-vars.sh
- |
if [ "$DOCKER_READY" ]; then
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
OSCP-Cluster-Mode:
tags:
- oscp
stage: Test
before_script:
- source shared-vars.sh
only:
- schedules
allow_failure: true
script:
- |
SESSION=$(echo $BUILD_IMG_TAG | awk -F ':' '{print $2}')
sed -i "/bigip_controller_img/c\ \"bigip_controller_img\": \"${BUILD_IMG_TAG}\"," ~/testenv_symbols/testenv_symbols.json
cd $HOME/${TEST_DIR} && scripts/run_systests.sh --project=bigip_ctlr --session=${SESSION}-cluster --include-tags="${INCLUDE_TAGS}" --orchestration=openshift --pool-mode=cluster --namespace-mode=${NAMESPACE_MODE} --exclude-tags="${EXCLUDE_TAGS}";
if [ $(cat $HOME/test_results/${SESSION}-cluster/${SESSION}-cluster-sessionresult.json | jq -r '.result') != "pass" ]; then echo "Test failed"; exit 1; fi
OSCP-Nodeport-Mode:
tags:
- oscp
stage: Test
before_script:
- source shared-vars.sh
only:
- schedules
allow_failure: true
script:
- |
SESSION=$(echo $BUILD_IMG_TAG | awk -F ':' '{print $2}')
sed -i "/bigip_controller_img/c\ \"bigip_controller_img\": \"${BUILD_IMG_TAG}\"," ~/testenv_symbols/testenv_symbols.json
cd $HOME/${TEST_DIR} && scripts/run_systests.sh --project=bigip_ctlr --session=${SESSION}-nodeport --include-tags="${INCLUDE_TAGS}" --orchestration=openshift --pool-mode=nodeport --namespace-mode=${NAMESPACE_MODE} --exclude-tags="${EXCLUDE_TAGS}" ;
if [ $(cat $HOME/test_results/${SESSION}-nodeport/${SESSION}-nodeport-sessionresult.json | jq -r '.result') != "pass" ]; then echo "Test failed"; exit 1; fi
K8s-Cluster-Mode:
tags:
- k8s
stage: Test
before_script:
- source shared-vars.sh
only:
- schedules
allow_failure: true
script:
- |
SESSION=$(echo $BUILD_IMG_TAG | awk -F ':' '{print $2}')
sed -i "/bigip_controller_img/c\ \"bigip_controller_img\": \"${BUILD_IMG_TAG}\"," ~/testenv_symbols/testenv_symbols.json
cd $HOME/${TEST_DIR} && scripts/run_systests.sh --project=bigip_ctlr --session=${SESSION}-cluster --include-tags="${INCLUDE_TAGS}" --orchestration=k8s --pool-mode=cluster --namespace-mode=${NAMESPACE_MODE} --exclude-tags="${EXCLUDE_TAGS}";
if [ $(cat $HOME/test_results/${SESSION}-cluster/${SESSION}-cluster-sessionresult.json | jq -r '.result') != "pass" ]; then echo "Test failed"; exit 1; fi
K8s-Nodeport-Mode:
tags:
- k8s
stage: Test
before_script:
- source shared-vars.sh
only:
- schedules
allow_failure: true
script:
- |
SESSION=$(echo $BUILD_IMG_TAG | awk -F ':' '{print $2}')
sed -i "/bigip_controller_img/c\ \"bigip_controller_img\": \"${BUILD_IMG_TAG}\"," ~/testenv_symbols/testenv_symbols.json
cd $HOME/${TEST_DIR} && scripts/run_systests.sh --project=bigip_ctlr --session=${SESSION}-nodeport --include-tags="${INCLUDE_TAGS}" --orchestration=k8s --pool-mode=nodeport --namespace-mode=${NAMESPACE_MODE} --exclude-tags="${EXCLUDE_TAGS}";
if [ $(cat $HOME/test_results/${SESSION}-nodeport/${SESSION}-nodeport-sessionresult.json | jq -r '.result') != "pass" ]; then echo "Test failed"; exit 1; fi