-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathJenkinsfileSCM
174 lines (174 loc) · 6.33 KB
/
JenkinsfileSCM
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
pipeline {
agent {
kubernetes {
inheritFrom 'kaniko'
yamlFile 'agent.pod.yaml'
defaultContainer 'rdepot-build'
yamlMergeStrategy merge()
}
}
options {
buildDiscarder(logRotator(numToKeepStr: '3'))
}
environment {
VERSION = sh(returnStdout: true, script: 'mvn help:evaluate -Dexpression=project.version -q -DforceStdout').trim()
NS = 'openanalytics'
DOCKER_BUILDKIT = '1'
REGISTRY = 'registry.openanalytics.eu'
NO_COLOR = 'true'
}
stages {
stage('license check') {
steps {
sh "mvn com.mycila:license-maven-plugin:check"
}
}
stage('static code analysis') {
steps {
sh "mvn clean install -DskipTests -Ddependency-check.skip=true -Perrorprone com.github.spotbugs:spotbugs-maven-plugin:check"
sh "mvn pmd:pmd"
}
}
stage('build test images and publish') {
steps {
container('kaniko') {
sh """
/kaniko/executor \
-v info \
--context ${env.WORKSPACE}/rdepot-app/src/test/resources/docker/app \
--cache=true \
--cache-repo ${env.REGISTRY}/${env.NS}/rdepot-app-it-cache \
--log-format=text \
--log-timestamp=true \
--cleanup \
--destination ${env.REGISTRY}/${env.NS}/rdepot-app-it:${env.VERSION}
"""
sh """
/kaniko/executor \
-v info \
--context ${env.WORKSPACE}/rdepot-app/src/test/resources/docker/repo \
--cache=true \
--cache-repo ${env.REGISTRY}/${env.NS}/rdepot-repo-it-cache \
--log-format=text \
--log-timestamp=true \
--cleanup \
--destination ${env.REGISTRY}/${env.NS}/rdepot-repo-it:${env.VERSION}
"""
}
}
post {
always {
sh "cp /kaniko/jenkins/mem*.log ${env.WORKSPACE}"
archiveArtifacts artifacts: 'mem*.log', fingerprint: true
}
}
}
stage('tests') {
steps {
configFileProvider([configFile(fileId: 'maven-settings-rsb', variable: 'MAVEN_SETTINGS_RSB')]) {
sh "mvn -s $MAVEN_SETTINGS_RSB clean deploy -Ddependency-check.skip=true"
}
publishHTML([
reportDir: 'rdepot-app/target/site/', reportFiles: 'failsafe-report.html',
reportName: 'Integration Test / App Test Report',
allowMissing: true, alwaysLinkToLastBuild: true, keepAll: true])
publishHTML([
reportDir: 'rdepot-repo/target/site/', reportFiles: 'surefire-report.html',
reportName: 'Repo Test Report',
allowMissing: true, alwaysLinkToLastBuild: true, keepAll: true])
publishHTML([
reportDir: 'rdepot-r-module/target/site/', reportFiles: 'surefire-report.html',
reportName: 'R Module Test Report',
allowMissing: true, alwaysLinkToLastBuild: true, keepAll: true])
publishHTML([
reportDir: 'rdepot-python-module/target/site/', reportFiles: 'surefire-report.html',
reportName: 'Python Module Test Report',
allowMissing: true, alwaysLinkToLastBuild: true, keepAll: true])
publishHTML([
reportDir: 'target/', reportFiles: 'dependency-check-report.html',
reportName: 'OWASP Dependency Analysis Report',
allowMissing: true, alwaysLinkToLastBuild: true, keepAll: true])
}
}
stage('build images') {
steps {
container('kaniko') {
sh """
/kaniko/executor \
-v info \
--context ${env.WORKSPACE} \
--cache=true \
--cache-repo ${env.REGISTRY}/${env.NS}/rdepot-app-cache \
--no-push \
--log-format=text \
--log-timestamp=true \
--cleanup \
--dockerfile ${env.WORKSPACE}/docker/build/app-standalone/Dockerfile
"""
sh """
/kaniko/executor \
-v info \
--context ${env.WORKSPACE} \
--cache=true \
--cache-repo ${env.REGISTRY}/${env.NS}/rdepot-repo-cache \
--no-push \
--log-format=text \
--log-timestamp=true \
--cleanup \
--dockerfile ${env.WORKSPACE}/docker/build/repo-standalone/Dockerfile
"""
}
}
post {
always {
sh "cp /kaniko/jenkins/mem*.log ${env.WORKSPACE}"
archiveArtifacts artifacts: 'mem*.log', fingerprint: true
}
}
}
stage('publish images') {
when {
anyOf {
branch 'develop'
branch 'master'
}
}
steps {
container('kaniko') {
sh """
/kaniko/executor \
-v info \
--context ${env.WORKSPACE} \
--log-format=text \
--log-timestamp=true \
--cache=true \
--cache-repo ${env.REGISTRY}/${env.NS}/rdepot-app-cache \
--cleanup \
--dockerfile ${env.WORKSPACE}/docker/build/app-standalone/Dockerfile \
--destination ${env.REGISTRY}/${env.NS}/rdepot-app:${env.VERSION} \
--destination ${env.REGISTRY}/${env.NS}/rdepot-app:latest
"""
sh """
/kaniko/executor \
-v info \
--context ${env.WORKSPACE} \
--log-format=text \
--log-timestamp=true \
--cache=true \
--cache-repo ${env.REGISTRY}/${env.NS}/rdepot-repo-cache \
--cleanup \
--dockerfile ${env.WORKSPACE}/docker/build/repo-standalone/Dockerfile \
--destination ${env.REGISTRY}/${env.NS}/rdepot-repo:${env.VERSION} \
--destination ${env.REGISTRY}/${env.NS}/rdepot-repo:latest
"""
}
}
post {
always {
sh "cp /kaniko/jenkins/mem*.log ${env.WORKSPACE}"
archiveArtifacts artifacts: 'mem*.log', fingerprint: true
}
}
}
}
}