@@ -53,8 +53,6 @@ pipeline {
53
53
54
54
PR_BRANCH_HASH = "${util.generateHash(10)}"
55
55
56
- // Maven configuration
57
- MAVEN_DEPLOY_LOCAL_DIR = "/tmp/maven_deploy_dir"
58
56
}
59
57
60
58
stages {
@@ -134,13 +132,21 @@ pipeline {
134
132
stage('Build OptaPlanner') {
135
133
steps {
136
134
script {
137
- configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){
138
- getOptaplannerMavenCommand()
139
- .withProperty('maven.test.failure.ignore', true)
140
- .withProperty('operator.image.build')
141
- .skipTests(params.SKIP_TESTS)
142
- .withSettingsXmlFile(MAVEN_SETTINGS_FILE)
143
- .run('clean install')
135
+ withCredentials([usernamePassword(credentialsId: env.MAVEN_REPO_CREDS_ID, usernameVariable: 'REPOSITORY_USER', passwordVariable: 'REPOSITORY_TOKEN')]) {
136
+ def installOrDeploy
137
+ if (shouldDeployToRepository()) {
138
+ installOrDeploy = "deploy -DdeployAtEnd -Dapache.repository.username=${REPOSITORY_USER} -Dapache.repository.password=${REPOSITORY_TOKEN} -DretryFailedDeploymentCount=5"
139
+ } else {
140
+ installOrDeploy = 'install'
141
+ }
142
+ configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){
143
+ getOptaplannerMavenCommand()
144
+ .withProperty('maven.test.failure.ignore', true)
145
+ .withProperty('operator.image.build')
146
+ .skipTests(params.SKIP_TESTS)
147
+ .withSettingsXmlFile(MAVEN_SETTINGS_FILE)
148
+ .run("clean $installOrDeploy")
149
+ }
144
150
}
145
151
if (isRelease()) {
146
152
updateAntoraYaml(optaplannerFolder)
@@ -178,46 +184,6 @@ pipeline {
178
184
}
179
185
}
180
186
}
181
- stage('Deploy locally') {
182
- steps {
183
- script {
184
- runMavenDeploy(getOptaplannerMavenCommand(), optaplannerRepository)
185
- }
186
- }
187
- }
188
- stage('Deploy to repository') {
189
- when {
190
- expression { return shouldDeployToRepository() }
191
- }
192
- steps {
193
- script {
194
- withCredentials([usernamePassword(credentialsId: env.MAVEN_REPO_CREDS_ID, usernameVariable: 'REPOSITORY_USER', passwordVariable: 'REPOSITORY_TOKEN')]) {
195
- configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]) {
196
- new MavenCommand(this)
197
- .withSettingsXmlFile(MAVEN_SETTINGS_FILE)
198
- .withProperty('wagon.source', "file://${getLocalDeploymentFolder(optaplannerRepository)}")
199
- .withProperty('wagon.target', MAVEN_DEPLOY_REPOSITORY)
200
- .withProperty('wagon.targetId', 'apache-snapshots-repository')
201
- .withProperty('apache.snapshot.repository.username', REPOSITORY_USER)
202
- .withProperty('apache.snapshot.repository.password', REPOSITORY_TOKEN)
203
- .run("org.codehaus.mojo:wagon-maven-plugin:2.0.2:merge-maven-repos")
204
- }
205
- }
206
- }
207
- }
208
- }
209
-
210
- // stage('Upload artifacts to given repository') {
211
- // when {
212
- // expression { return isSpecificArtifactsUpload() }
213
- // }
214
- // steps {
215
- // script {
216
- // // Deploy to specific repository with credentials
217
- // maven.uploadLocalArtifacts(env.MAVEN_REPO_CREDS_ID, getLocalDeploymentFolder(optaplannerRepository), getMavenRepoZipUrl())
218
- // }
219
- // }
220
- // }
221
187
stage('Stage artifacts') {
222
188
when {
223
189
expression { return shouldStageArtifacts() }
@@ -450,32 +416,8 @@ String getMavenRepoZipUrl() {
450
416
return "${params.MAVEN_DEPLOY_REPOSITORY.replaceAll('/content/', '/service/local/').replaceFirst('/*$', '')}/content-compressed"
451
417
}
452
418
453
- void runMavenStage(MavenCommand mvnCmd, String localDeployId) {
454
- MavenStagingHelper stagingHelper = getStagingHelper(mvnCmd)
455
- deployProperties.putAll(stagingHelper.stageLocalArtifacts(env.NEXUS_STAGING_PROFILE_ID, getLocalDeploymentFolder(localDeployId)))
456
- stagingHelper.promoteStagingRepository(env.NEXUS_BUILD_PROMOTION_PROFILE_ID)
457
- }
458
-
459
- MavenStagingHelper getStagingHelper(MavenCommand mvnCmd) {
460
- return new MavenStagingHelper(this, mvnCmd)
461
- .withNexusReleaseUrl(env.NEXUS_RELEASE_URL)
462
- .withNexusReleaseRepositoryId(env.NEXUS_RELEASE_REPOSITORY_ID)
463
- }
464
-
465
- String getLocalDeploymentFolder(String localDeployId) {
466
- return "${env.MAVEN_DEPLOY_LOCAL_DIR}/${localDeployId}"
467
- }
468
-
469
419
// Getters and Setters of params/properties
470
420
471
- boolean isSpecificArtifactsUpload() {
472
- return env.MAVEN_DEPLOY_REPOSITORY && env.MAVEN_REPO_CREDS_ID && !isDeployDisabled()
473
- }
474
-
475
- boolean shouldStageArtifacts() {
476
- return !isSpecificArtifactsUpload() && isRelease() && !env.MAVEN_DEPLOY_REPOSITORY && !isDeployDisabled()
477
- }
478
-
479
421
boolean shouldDeployToRepository() {
480
422
return (env.MAVEN_DEPLOY_REPOSITORY || isNotTestingBuild()) && !isDeployDisabled()
481
423
}
0 commit comments