@@ -18,7 +18,7 @@ env.ARTIFACTORY_PATH=''
18
18
env. ID = ' '
19
19
env. PROJECT = ' '
20
20
21
- env . DOCKER_REGISTRY = " ${ DOCKER_REGISTRY } "
21
+ IMAGE_NAMES_MAP = [:]
22
22
23
23
pipeline {
24
24
agent none
@@ -45,31 +45,30 @@ pipeline {
45
45
}
46
46
}
47
47
}
48
-
49
48
stage(" Build & Sign & Upload to Artifactory" ) {
50
49
agent none
51
50
steps {
52
51
script {
53
52
buildInParallel= [:]
54
53
YAML_CONFIG . build. each {
55
54
buildInParallel[" Build ${ it.name} " ] = { ->
56
-
57
55
node (it. hostmachine_jenkins_label) {
58
56
checkout scm
59
- build(it)
57
+ validateBuildImage(it)
58
+ echo " Using image: ${ IMAGE_NAMES_MAP[it.name]} "
59
+ buildStage(it)
60
60
if (it. rpmSign == true )
61
61
signing. rpmSign(" dist" )
62
- getVersionAndUploadToArtifactory()
62
+ getVersionAndUploadToArtifactory(it )
63
63
}
64
-
65
64
}
66
- }
65
+ }
67
66
parallel buildInParallel
68
67
}
69
68
}
70
69
}
71
70
72
- stage (" Whitesource Scan" ) {
71
+ stage (" OWASP Scan" ) {
73
72
agent {label " redhat8" }
74
73
when {
75
74
equals (actual : YAML_CONFIG . whitesourceScan, expected : true )
@@ -78,18 +77,6 @@ pipeline {
78
77
script {
79
78
checkout scm
80
79
ws. dockerScan()
81
- /* Get token of product. We have to communicate with WS API only using 64-digits project's token.
82
- We are sending request to API and get ALL "project+token" pairs. Then parse this information and find token for current project*/
83
- productToken = ws. getWSProductToken()
84
-
85
- // Get reports (Excel and json) from WS site and save these reports to files. Once for each format
86
- ws. getWSReports(productToken)
87
-
88
- // Move latest reports to the "old" folder in Artifactory
89
- ws. moveOldWsReports(ARTIFACTORY_SERVER )
90
-
91
- // Upload reports (Excel and json) to the Artifactory (to the latest folder)
92
- ws. uploadToArtifactory(ARTIFACTORY_SERVER )
93
80
}
94
81
}
95
82
}
@@ -124,42 +111,14 @@ pipeline {
124
111
}
125
112
}
126
113
127
- def build (yamlCurrentBuildItem ) {
128
- def image = yamlCurrentBuildItem. image
129
- def imageContext = yamlCurrentBuildItem. imageContext
130
-
131
- if (image) {
132
- image = image. replace(" _DOCKER_REGISTRY_" , DOCKER_REGISTRY )
133
- }
134
-
135
- if (imageContext) {
136
- if (image) {
137
- error " You can not specify 'image' and 'imageContext' options in build-config.yaml"
138
- }
139
- def imageTagScript = yamlCurrentBuildItem. imageTagScript
140
- image = sh script : imageTagScript, returnStdout : true
141
- image = image. trim()
142
- def imageCheckStatus = sh script : " docker inspect -f . '${ image} '" , returnStatus : true
143
- if (imageCheckStatus != 0 ) {
144
- imageCheckStatus = sh script : " docker pull '${ image} '" , returnStatus : true
145
- }
146
- if (imageCheckStatus != 0 ) {
147
- sh """
148
- docker build \
149
- --build-arg DOCKER_REGISTRY='${ DOCKER_REGISTRY} ' \
150
- -t '${ image} ' \
151
- '${ imageContext} '
152
- docker push '${ image} '
153
- """
154
- }
155
- }
156
-
114
+ def buildStage (yamlCurrentBuildItem ) {
157
115
def buildCommand = yamlCurrentBuildItem. basicBuildCommands. replace(" _BUILD_ENV_VARS_" ," TIMESTAMP=${ ID} DO_DEPLOY=${ params.DO_DEPLOY} ${ params.BUILD_ENV_VARS} " )
158
116
159
117
configFileProvider([configFile(fileId : ' maven_settings_spark_deploy_mvn381_above' , variable : ' mvn_settings' )]) {
160
118
sh " cat ${ env.mvn_settings} > settings.xml"
161
119
}
162
- docker. image(image). inside (
120
+
121
+ docker. image(IMAGE_NAMES_MAP [yamlCurrentBuildItem. name]). inside (
163
122
" -e MAPR_MIRROR=${ MAPR_MIRROR} \
164
123
-e MAPR_CENTRAL=${ MAPR_CENTRAL} \
165
124
-e MAVEN_CENTRAL=${ MAVEN_CENTRAL} \
@@ -185,7 +144,25 @@ def build(yamlCurrentBuildItem) {
185
144
}
186
145
}
187
146
188
- def getVersionAndUploadToArtifactory () {
189
- def osVersionContainerRaw = sh script : ' cat os_release_version.txt' , returnStdout :true
190
- artifactory. uploadToArtifactoryWithOSVersions(ARTIFACTORY_SERVER , osVersionContainerRaw)
147
+ def validateBuildImage (yamlCurrentBuildItem ) {
148
+ def imageStatic = yamlCurrentBuildItem. image
149
+ def imageCustom = yamlCurrentBuildItem. imageCustom
150
+ def imageName = " "
151
+ if (imageStatic) {
152
+ imageName = imageStatic. replace(" _DOCKER_REGISTRY_" , DOCKER_REGISTRY )
153
+ }
154
+ if (imageCustom) {
155
+ if (imageStatic) {
156
+ error " You can not specify 'image' and 'imageCustom' options in build-config.yaml"
157
+ }
158
+ imageName = sh(script : imageCustom, returnStdout : true ). trim()
159
+ }
160
+ IMAGE_NAMES_MAP [yamlCurrentBuildItem. name] = imageName
161
+ }
162
+
163
+ def getVersionAndUploadToArtifactory (yamlCurrentBuildItem ) {
164
+ stage(" Get Version And Upload to Artifactory stage:${ yamlCurrentBuildItem.name} " ) {
165
+ def osVersionContainerRaw = sh script : ' cat os_release_version.txt' , returnStdout :true
166
+ artifactory. uploadToArtifactoryWithOSVersions(ARTIFACTORY_SERVER , osVersionContainerRaw)
167
+ }
191
168
}
0 commit comments