-
Notifications
You must be signed in to change notification settings - Fork 60
/
Jenkinsfile
202 lines (191 loc) · 10.1 KB
/
Jenkinsfile
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
def qualifier
pipeline {
agent {
dockerfile {
dir 'verinice-distribution/docker-verinice-builder'
args '-v $MAVEN_REPOSITORY_BASE/repository$EXECUTOR_NUMBER:/m2/repository -v $HOME/.cache/verinicebuild:/cache/verinicebuild'
}
}
environment {
// In case the build server exports a custom JAVA_HOME, we fix the JAVA_HOME
// to the one used by the docker image.
JAVA_HOME='/usr/lib/jvm/java-17-openjdk'
}
parameters {
booleanParam(name: 'runIntegrationTests', defaultValue: true, description: 'Run integration tests')
booleanParam(name: 'runRCPTTTests', defaultValue: true, description: 'Run RCPTT tests')
booleanParam(name: 'clientSign', defaultValue: false, description: 'Sign verinice clients')
booleanParam(name: 'dists', defaultValue: false, description: 'Run distribution steps, i.e. build RPMs files etc.')
// We need an extra flag. Unfortunately it is not possible to find out, if a password is left empty.
booleanParam(name: 'distSign', defaultValue: false, description: 'Sign RPM packages')
password(name: 'GNUPGPASSPHRASE', description: 'The passphrase of the key stored in KEYDIR/verinice.public.')
booleanParam(name: 'archiveUpdateSite', defaultValue: false, description: 'archive the update site')
booleanParam(name: 'archiveIntegrationTestResults', defaultValue: false, description: 'archive the integration test results')
booleanParam(name: 'generateSNCAReport', defaultValue: false, description: 'generate the snca report/validation with snca editor')
}
options {
buildDiscarder(logRotator(numToKeepStr: '3'))
}
stages {
stage('Setup') {
steps {
script {
qualifier = "v${new Date().format('yyyyMMddHHmmss')}"
echo "Using build qualifier $qualifier"
if (params.distSign && !params.dists) {
def msg = 'You have to enable dists, if you want to sign packages.'
buildDescription msg
error msg
}
def targetPlatform = 'target-platform/target-platform.target'
def content = readFile(file: targetPlatform, encoding: 'UTF-8')
def repositoryLocations = content.findAll('location\\s*=\\s*"([^"]+)"'){it[1]}
if (env.TAG_NAME){
currentBuild.keepLog = true
def repositoriesOnBob = repositoryLocations.findAll{it =~ /\bbob\b/}
if (!repositoriesOnBob.isEmpty()){
error("Target platform uses repositories on bob: $repositoriesOnBob")
}
}
def httpRepositories = repositoryLocations.findAll{it =~ /http:/}.findAll{!(it =~ '^http://bob(-2023)?\\.')}
if (!httpRepositories.isEmpty()){
error("Target platform uses non-HTTPS repositories: $httpRepositories")
}
}
buildDescription "${env.GIT_BRANCH} ${env.GIT_COMMIT[0..8]}"
sh "./verinice-distribution/build.sh QUALIFIER=${qualifier} clean"
}
}
stage('Build') {
steps {
script {
def buildTask = params.runIntegrationTests ? 'verify' : 'products'
sh "./verinice-distribution/build.sh QUALIFIER=${qualifier} ${buildTask}"
archiveArtifacts artifacts: 'sernet.verinice.releng.client.product/target/products/*.zip,sernet.verinice.releng.server.product/target/*.war', fingerprint: true
if (params.archiveUpdateSite || params.dists){
archiveArtifacts artifacts: 'sernet.verinice.releng.client.product/target/repository/**', fingerprint: true
}
if (params.runIntegrationTests){
junit allowEmptyResults: true, testResults: '**/build/reports/**/*.xml,**/target/surefire-reports/*.xml'
if (params.archiveIntegrationTestResults){
archiveArtifacts artifacts: '**/build/reports/**/*.xml,**/target/surefire-reports/*.xml'
}
}
}
}
}
stage('Trigger RCPTT') {
when { expression { params.runRCPTTTests } }
steps {
// normal client rcptt
// the last parameter can be adjusted to control which tests are to be run
// e.g. 'bp*.test'
runStandaloneUITests tests: '*.test'
// 3-tier test
// the last parameter can be adjusted to control which tests are to be run
// e.g. 'bp*.test'
// run3TierUITests tests: '*.test'
// report verinice en and de
// triggerRCPTTBuild 'rcptt-all-report-tests'
// product tests
//product tests partially is broken see VN-2882
// triggerRCPTTBuild 'rcptt-product-report-test'
// performance tests
// the last parameter can be adjusted to control which tests are to be run
// e.g. 'bp_delete-import-performance.test'
// triggerRCPTTBuild 'rcptt-client-performance-test', '*-performance.test'
// triggerRCPTTBuild 'rcptt-server-performance-test', '*-performance.test'
// test specific operating systems
// runStandaloneUITests os: 'Linux', tests: '*.test'
// runStandaloneUITests os: 'macOS current', tests: '*.test'
// runStandaloneUITests os: 'macOS predecessor', tests: '*.test'
// runStandaloneUITests os: 'Windows 10', tests: '*.test'
}
}
stage('generate SNCA Report') {
when { expression { params.generateSNCAReport } }
steps {
archiveArtifacts artifacts: 'sernet.gs.server/WebContent/WEB-INF/SNCA.xml,sernet.gs.server/WebContent/WEB-INF/snca-messages*.properties', fingerprint: true
build job: 'snca-report', wait: false, parameters: [
string(name: 'job_to_copy_from', value: "${currentBuild.fullProjectName}"),
string(name: 'build_to_copy_from', value: "<SpecificBuildSelector plugin=\"[email protected]\"><buildNumber>${env.BUILD_NUMBER}</buildNumber></SpecificBuildSelector>"),
]
}
}
stage('Documentation') {
steps {
sh "./verinice-distribution/build.sh QUALIFIER=${qualifier} -j4 docs"
archiveArtifacts artifacts: 'doc/manual/*/*.pdf,doc/manual/*/*.zip', fingerprint: true
}
}
stage('Sign clients') {
when {
expression { params.clientSign && currentBuild.result in [null, 'SUCCESS'] }
}
steps {
script {
def fileNameWindows = sh returnStdout: true, script: 'ls sernet.verinice.releng.client.product/target/products/*win32*zip'
def windowsClientUrl = input message: 'Supply URLS to client ZIPs with signed executables', parameters: [string(name: 'windows', description: 'URL to Windows Client ZIP')], submitter: 'dm'
sh "rm $fileNameWindows"
sh "curl $windowsClientUrl --output $fileNameWindows"
archiveArtifacts artifacts: 'sernet.verinice.releng.client.product/target/products/*.zip', fingerprint: true
}
}
}
stage('Distributions') {
when {
expression { params.dists && currentBuild.result in [null, 'SUCCESS'] }
}
steps {
sh "./verinice-distribution/build.sh QUALIFIER=${qualifier} -j2 dists"
}
}
// Signing is a separate step because we want to be able to build RPMs any time, to test them.
// However RPMs are only archived if they are signed.
stage('Distributions Signing') {
when {
expression { params.distSign && currentBuild.result in [null, 'SUCCESS'] }
}
steps {
sh "./verinice-distribution/sign-rpms verinice-distribution/rhel-?/RPMS/noarch/*"
archiveArtifacts artifacts: 'verinice-distribution/rhel-?/RPMS/noarch/*', fingerprint: true
}
}
}
post {
always {
recordIssues(tools: [mavenConsole()])
recordIssues(tools: [java()])
recordIssues(tools: [taskScanner(highTags: 'FIXME', ignoreCase: true, normalTags: 'TODO', includePattern: '**/*.java, **/*.xml')])
}
failure {
emailext body: '${JELLY_SCRIPT,template="text"}', subject: '$DEFAULT_SUBJECT', to: '[email protected], [email protected], [email protected], [email protected]'
}
success {
sh './verinice-distribution/build.sh QUALIFIER=${qualifier} clean'
}
}
}
def run3TierUITests(Map opts = [:]){
triggerRCPTTBuild('rcptt-server-test', opts)
}
def runStandaloneUITests(Map opts = [:]){
triggerRCPTTBuild('rcptt-client-test', opts)
}
def triggerRCPTTBuild(String jobName, String testList){
triggerRCPTTBuild(jobName, [tests: testList])
}
def triggerRCPTTBuild(String jobName, Map opts = [:]){
def parameters = [
gitParameter(name: 'BRANCH_OR_TAG', value: "${env.GIT_BRANCH}"),
string(name: 'job_to_copy_from', value: "${currentBuild.fullProjectName}"),
string(name: 'build_to_copy_from', value: "<SpecificBuildSelector plugin=\"[email protected]\"><buildNumber>${env.BUILD_NUMBER}</buildNumber></SpecificBuildSelector>"),
string(name: 'OPERATING_SYSTEM', value: opts.os ?: 'any')
]
String testList = opts.tests
if (testList != null){
parameters << string(name: 'test-list', value: testList)// support the old jobs
parameters << string(name: 'TEST_LIST', value: testList)
}
build job: jobName, wait: false, parameters: parameters
}