-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
198 lines (182 loc) · 4.86 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_COMMIT_REF_SLUG
GIT_SUBMODULE_STRATEGY: recursive
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- deps/
stages:
- build_deps
- build
- unittests
- coverage
- build_rpms
- on_rpm_tests
- deploy_release
- deploy_snapshot
- service_update
before_script:
- export REPORT_FNAME=results.$(date +%d-%m-%Y-%H_%M_%S)
- if [[ $(cat build/version.txt) =~ ([0-9]+\.[0-9]+\.[0-9]+)\.([0-9]+)_([A-Z]+) ]] ; then export VERSION=${BASH_REMATCH[1]};export SNAPSHOT=${BASH_REMATCH[2]};export RELEASE=${BASH_REMATCH[3]}; fi
- if [ "$RELEASE" = "SNAPSHOT" ]; then export REPO=snapshots ;export POM_SNAPSHOT='-SNAPSHOT'; else export POM_SNAPSHOT= ;export REPO=releases; fi
- NEXUS_URL_PREFIX="https://${NEXUS_HOSTNAME}/content/repositories/${REPO}"
- MAX_PRIOR_ITERATION=0; PRIOR_RPM_ITERATIONS=$(curl "${NEXUS_URL_PREFIX}/com/trustwave/cdcm/maven-metadata.xml" | sed -nE "s/<version>${VERSION}.([[:digit:]]+)${POM_SNAPSHOT}<\/version>/\1/p")
- for PRIOR_ITERATION in ${PRIOR_RPM_ITERATIONS}; do ((PRIOR_ITERATION > MAX_PRIOR_ITERATION)) && MAX_PRIOR_ITERATION=${PRIOR_ITERATION}; done
- export ITERATION=$((++MAX_PRIOR_ITERATION))
- export CMAKE_FLAGS='-DBUILD_DEV=OFF'
- if [ -z $CI_COMMIT_TAG ]; then export CMAKE_FLAGS='-DBUILD_DEV=ON' ; fi;
- env
after_script:
- echo "After script section"
build_deps:
stage: build_deps
script:
- /bin/bash ci_scripts/build_deps.bash
rules:
- if: '$CI_PIPELINE_SOURCE == "push"'
- if: '$CI_PIPELINE_SOURCE == "trigger" && $ACTION != "update_service"'
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- deps/
policy: pull-push
tags:
- cdcm
build:
stage: build
variables:
DEPS_DIR: $CI_PROJECT_DIR/deps
script:
- /bin/bash ci_scripts/build.bash
rules:
- if: '$CI_PIPELINE_SOURCE == "push"'
- if: '$CI_PIPELINE_SOURCE == "trigger" && $ACTION != "update_service"'
artifacts:
paths:
- build_cdcm/
expire_in: 10 days
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- deps/
policy: pull
tags:
- cdcm
dependencies:
- build_deps
unittests:
stage: unittests
script:
- scl enable devtoolset-8 'bash ci_scripts/unittests.bash'
rules:
- if: '$CI_PIPELINE_SOURCE == "push"'
- if: '$CI_PIPELINE_SOURCE == "trigger" && $ACTION != "update_service"'
artifacts:
when: always
paths:
- build_cdcm/src/cdcm_testing/*.xml
- build_cdcm/src/cdcm_testing/*.html
- build_cdcm/src/cdcm_testing/log/cdcm_client.log
reports:
junit: build_cdcm/src/tests/*.xml
expire_in: 10 days
tags:
- cdcm
dependencies:
- build
html_coverage:
stage: coverage
script:
- scl enable devtoolset-8 "bash ci_scripts/html_coverage.bash"
artifacts:
name: pages
when: always
paths:
- build_cdcm/src/html_coverage
expire_in: 10 days
rules:
- if: '$CI_PIPELINE_SOURCE == "push"'
- if: '$CI_PIPELINE_SOURCE == "trigger" && $ACTION != "update_service"'
tags:
- cdcm
dependencies:
- build
build_rpms:
stage: build_rpms
script:
- scl enable devtoolset-8 "bash ci_scripts/build_rpm.bash"
rules:
- if: '$CI_PIPELINE_SOURCE == "push"'
- if: '$CI_PIPELINE_SOURCE == "trigger" && $ACTION != "update_service"'
artifacts:
paths:
- build/RPMS/x86_64/
expire_in: 10 days
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- deps/
policy: pull
tags:
- cdcm
dependencies:
- build
smoke_test:
stage: on_rpm_tests
script:
- bash ci_scripts/smoke_test.bash
rules:
- if: '$CI_PIPELINE_SOURCE == "push"'
- if: '$CI_PIPELINE_SOURCE == "trigger" && $ACTION != "update_service"'
allow_failure: true
artifacts:
expire_in: 10 days
when: always
paths:
- ./*.log
tags:
- cdcm_smoke
dependencies:
- build_rpms
test_install:
stage: on_rpm_tests
tags:
- cdcm_install
script:
- bash ci_scripts/test_install.bash
rules:
- if: '$CI_PIPELINE_SOURCE == "push"'
- if: '$CI_PIPELINE_SOURCE == "trigger" && $ACTION != "update_service"'
dependencies:
- build_rpms
deploy_release:
stage: deploy_release
script:
- scl enable devtoolset-8 "bash ci_scripts/deploy.bash"
rules:
- if: '$CI_PIPELINE_SOURCE == "trigger" && $ACTION == "deploy_release"'
tags:
- cdcm
dependencies:
- build_rpms
deploy_snapshot:
stage: deploy_snapshot
script:
- scl enable devtoolset-8 "bash ci_scripts/deploy.bash"
rules:
- if: '$CI_PIPELINE_SOURCE == "trigger" && $ACTION == "deploy_snapshot"'
tags:
- cdcm
dependencies:
- build_rpms
service_update:
stage: service_update
script:
- bash ci_scripts/service_update.bash
rules:
- if: '$CI_PIPELINE_SOURCE == "trigger" && $ACTION == "deploy_release"'
- if: '$CI_PIPELINE_SOURCE == "trigger" && $ACTION == "update_service"'
tags:
- cdcm_service
dependencies:
- deploy_release