This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
/
.gitlab-ci.yml.sample
265 lines (247 loc) · 7.5 KB
/
.gitlab-ci.yml.sample
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
# Pipeline managed stages
stages:
- Dependencies
- Build
- CodeReview
- Report
- Package
- Deploy
# Pipeline global variables
variables:
# Variables to active or disable zUnit/Code Coverage/Code Review and Report features.
RUN_ZUNIT_TEST: "false"
RUN_CODE_COVERAGE: "false"
RUN_IDZ_CODE_REVIEW : "false"
GITLAB_REPORT_UPLOAD: "false"
# z/OS Working directory
WORKING_DIR: "/u/jyvesb/builds/tuto/work/$CI_PIPELINE_ID"
# z/OS Report directory
REPORT_FOLDER: "/u/jyvesb/builds/tuto/report/$CI_PIPELINE_ID"
# DBB related variables
DBB_HOME: "/usr/lpp/IBM/dbb"
DBB_HLQ: "NAZARE.TUTO.GITLAB.GENAPP"
DBB_URL: "https://example.com:9443/dbb"
# Artificatory related variables (password is declared into your GibLab group)
ARTI_URL: "https://example.com"
ARTI_USERNAME: "arti-id"
ARTI_REPO_PATH: "arti-repo-generic-local/genapp/ucd/gitlab"
# UCD related variables (password is declared into your GibLab group)
UCD_BUZTOOL_PATH: "/usr/lpp/IBM/ucd/bin/buztool.sh"
UCD_URL: "https://example.com:8443"
UCD_USERNAME: "ucd-id"
# Code Coverage related variables only if RUN_CODE_COVERAGE: "true" and RUN_ZUNIT_TEST: "true"
CCC_INSTALL_FOLDER: "/usr/lpp/IBM/debug/headless-code-coverage"
# Report related variables (we use sftp to pull the build log/report from the z/OS)
# We assume that you have set up ssh key exchange between the distributed system and your z/OS.
# The report will be uploaded only when GITLAB_REPORT_UPLOAD="true". In this case
# you must have configured a GitLab runner shell executor as mentioned in the online tutorial.
ZOS_SFTP_HOST: "your-zos-host"
ZOS_SFTP_PORT: "22"
ZOS_SFTP_USER: "zos-id"
# Default values for the tutorial
UCD_APPPLICATION: "GenApp-Deploy"
UCD_PROCESS: "Deploy"
UCD_ENV: "Development"
UCD_COMPONENT: "GenAppComponent"
ARTI_PASSWORD: "$GROUP_ARTI_PASSWORD"
UCD_PASSWORD: "$GROUP_UCD_PASSWORD"
DBB_EXTRA_OPTS: "-d"
DBB_BUILD_TYPE: "-i"
DBB_CREDENTIAL_OPTIONS: "-id ADMIN -pw ADMIN"
CCC_HOST: "127.0.0.1"
CCC_PORT: "8006"
GIT_SSL_NO_VERIFY: "true"
CI_DEBUG_TRACE: "false"
# This stage will checkout the GitLab dbb project for DBB Build
dbb:
stage: Dependencies
trigger:
project: "YOUR_GIT_LAB_GROUP/dbb"
branch: master
strategy: depend
# This stage will checkout the GitLab dbb-zappbuild project for DBB Build
zAppBuild:
stage: Dependencies
trigger:
project: "YOUR_GIT_LAB_GROUP/dbb-zappbuild"
branch: development
strategy: depend
# This stage on the z/OS perform the DBB build with zUnit and Code Coverage (optional)
DBB Build:
stage: Build
dependencies: []
before_script:
- |
# Cleanup build and report folders
rm -rf $WORKING_DIR
mkdir -p $WORKING_DIR
rm -rf $REPORT_FOLDER
mkdir -p $REPORT_FOLDER
if [ "$RUN_CODE_COVERAGE" == "true" ] && [ "$RUN_ZUNIT_TEST" == "true" ]
then
$CCC_INSTALL_FOLDER/bin/ccstart.sh -port=$CCC_PORT -exportertype=CCPDF > $WORKING_DIR/ccc.log&
fi
script:
- |
#env
rc=0
if [ "$RUN_CODE_COVERAGE" == "true" ] && [ "$RUN_ZUNIT_TEST" == "true" ]
then
DBB_CCC_OPTS="-cc -cch ${CCC_HOST} -ccp ${CCC_PORT}"
fi
if [ "$RUN_ZUNIT_TEST" == "true" ]
then
DBB_ZUNIT_OPTS="-runzTests"
fi
set +e
set -o xtrace
$DBB_HOME/bin/groovyz\
$PWD/../dbb-zappbuild/build.groovy\
--application cics-genapp\
--logEncoding UTF-8 -w $PWD --sourceDir $PWD --workDir $WORKING_DIR\
--hlq ${DBB_HLQ} --url $DBB_URL $DBB_CREDENTIAL_OPTIONS $DBB_BUILD_TYPE $DBB_EXTRA_OPTS $DBB_CCC_OPTS $DBB_ZUNIT_OPTS
rc=$?
set +o xtrace
cp $WORKING_DIR/*/*.log $REPORT_FOLDER
cp $WORKING_DIR/*/*.json $REPORT_FOLDER
cp $WORKING_DIR/*/*.html $REPORT_FOLDER
for file in $(find $WORKING_DIR -name "*.zunit.report.log")
do
iconv -t IBM-1047 -f ISO8859-1 $file > $file.ibm1047.log
chtag -r $file.ibm1047.log
grep -q "FINISHED EXECUTION RC=04" $file.ibm1047.log
if [ $? == 0 ]
then
rc=1
fi
done
if [ "$RUN_CODE_COVERAGE" == "true" ] && [ "$RUN_ZUNIT_TEST" == "true" ]
then
mv -f $HOME/CC/*.pdf $REPORT_FOLDER
mv -f $HOME/CC/*.cczip $REPORT_FOLDER
$CCC_INSTALL_FOLDER/bin/ccstop.sh $CCC_PORT >> $WORKING_DIR/ccc.log
fi
exit $rc
tags:
- zos-ssh
# This stage on the z/OS perform IDz code review (optional)
IDz Code Review:
stage: CodeReview
dependencies: []
variables:
GIT_STRATEGY: none
GIT_CHECKOUT: "false"
only :
variables:
- $RUN_IDZ_CODE_REVIEW == 'true'
script:
- |
# env
rc=0
BUILD_OUTPUT_FOLDER=$(ls $WORKING_DIR | grep build | sort -u)
set -o xtrace
$DBB_HOME/bin/groovyz \
$PWD/../dbb/Pipeline/RunIDZCodeReview/RunCodeReview.groovy\
--workDir $WORKING_DIR/$BUILD_OUTPUT_FOLDER\
-cr $PWD/cics-genapp/cr-rules/CodeReviewRules.dat\
-ccr $PWD/cics-genapp/cr-rules/CodeReviewRules.ccr
rc=$?
set +o xtrace
if [ -f $WORKING_DIR/$BUILD_OUTPUT_FOLDER/CodeReviewJUNIT.xml ]
then
cp $WORKING_DIR/$BUILD_OUTPUT_FOLDER/CodeReviewJUNIT.xml $REPORT_FOLDER
fi
exit $rc
tags:
- zos-ssh
# This stage on the gitlab-runner instance pull the logs
# and zUnit outputs from the z/OS and publish then
# back to the GitLab CI pipeline board (optional).
Build Report:
stage: Report
dependencies: []
only :
variables:
- $GITLAB_REPORT_UPLOAD == 'true'
script:
- |
mkdir build_$CI_PIPELINE_ID
cd build_$CI_PIPELINE_ID
sftp -o "StrictHostKeyChecking=no" -P $ZOS_SFTP_PORT $ZOS_SFTP_USER@$ZOS_SFTP_HOST<<EOF
mget $REPORT_FOLDER/*
EOF
set +e
set -o xtrace
for file in $(find . -name "*.zunit.report.log")
do
xsltproc $CI_PROJECT_DIR/cics-genapp/zUnit/xsl/AZUZ2J30.xsl $file > $(basename $file).xml
grep -q "FINISHED EXECUTION RC=04" $(basename $file).xml
_rc=$?
echo "zUnit result for $file: $rc"
if [ $_rc -eq 0 ]
then
echo "zUnit failed for: $file!!!"
rc=1
fi
done
set -e
artifacts:
name: "report-${CI_PIPELINE_ID}"
when: always
paths:
- "build_${CI_PIPELINE_ID}/"
reports:
junit: "build_$CI_PIPELINE_ID/*.xml"
tags:
- dist-shell
# This stage on the z/OS build the UCD package/version
UCD Package:
stage: Package
dependencies: []
variables:
GIT_STRATEGY: none
GIT_CHECKOUT: "false"
script:
- |
# env
rc=0
cat <<EOF >> $WORKING_DIR/artifactoy.properties
Repository_type=artifactory
username=$ARTI_USERNAME
password=$ARTI_PASSWORD
repository=$ARTI_REPO_PATH
url=$ARTI_URL
EOF
BUILD_OUTPUT_FOLDER=$(ls $WORKING_DIR | grep build | sort -u)
set -o xtrace
$DBB_HOME/bin/groovyz \
$PWD/../dbb/Pipeline/CreateUCDComponentVersion/dbb-ucd-packaging.groovy\
--buztool $UCD_BUZTOOL_PATH --component $UCD_COMPONENT\
--workDir $WORKING_DIR/$BUILD_OUTPUT_FOLDER\
-ar $WORKING_DIR/artifactoy.properties
rc=$?
set +o xtrace
exit $rc
tags:
- zos-ssh
# This stage on the z/OS deploy the UCD package/version
UCD Deploy:
stage: Deploy
dependencies: []
variables:
GIT_STRATEGY: none
GIT_CHECKOUT: "false"
script:
- |
# env
rc=0
set -o xtrace
$DBB_HOME/bin/groovyz \
$PWD/../dbb/Pipeline/DeployUCDComponentVersion/ucd-deploy.groovy\
-a "$UCD_APPPLICATION" -e "$UCD_ENV" -U $UCD_USERNAME -P $UCD_PASSWORD\
-u $UCD_URL -d "$UCD_COMPONENT:latest" -p "$UCD_PROCESS" -k
rc=$?
set +o xtrace
exit $rc
tags:
- zos-ssh