Skip to content

Commit 01f55d2

Browse files
jstastny-czjstastny-cz
and
jstastny-cz
authored
[kie-issues#1123] adjust deploy operation (apache#3086)
Co-authored-by: jstastny-cz <jan.stastny@ibm.com>
1 parent f0bc7cf commit 01f55d2

File tree

2 files changed

+15
-81
lines changed

2 files changed

+15
-81
lines changed

.ci/jenkins/Jenkinsfile.deploy

+15-73
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ pipeline {
5353

5454
PR_BRANCH_HASH = "${util.generateHash(10)}"
5555

56-
// Maven configuration
57-
MAVEN_DEPLOY_LOCAL_DIR = "/tmp/maven_deploy_dir"
5856
}
5957

6058
stages {
@@ -134,13 +132,21 @@ pipeline {
134132
stage('Build OptaPlanner') {
135133
steps {
136134
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+
}
144150
}
145151
if (isRelease()) {
146152
updateAntoraYaml(optaplannerFolder)
@@ -178,46 +184,6 @@ pipeline {
178184
}
179185
}
180186
}
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-
// }
221187
stage('Stage artifacts') {
222188
when {
223189
expression { return shouldStageArtifacts() }
@@ -450,32 +416,8 @@ String getMavenRepoZipUrl() {
450416
return "${params.MAVEN_DEPLOY_REPOSITORY.replaceAll('/content/', '/service/local/').replaceFirst('/*$', '')}/content-compressed"
451417
}
452418

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-
469419
// Getters and Setters of params/properties
470420

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-
479421
boolean shouldDeployToRepository() {
480422
return (env.MAVEN_DEPLOY_REPOSITORY || isNotTestingBuild()) && !isDeployDisabled()
481423
}

.ci/jenkins/dsl/jobs.groovy

-8
Original file line numberDiff line numberDiff line change
@@ -313,14 +313,6 @@ void setupDeployJob(JobType jobType, String envName = '') {
313313
OPERATOR_IMAGE_NAME: 'optaplanner-operator',
314314
MAX_REGISTRY_RETRIES: 3,
315315
])
316-
if (jobType == JobType.RELEASE) {
317-
jobParams.env.putAll([
318-
NEXUS_RELEASE_URL: "${MAVEN_NEXUS_RELEASE_URL}",
319-
NEXUS_RELEASE_REPOSITORY_ID: "${MAVEN_NEXUS_RELEASE_REPOSITORY}",
320-
NEXUS_STAGING_PROFILE_ID: "${MAVEN_NEXUS_STAGING_PROFILE_ID}",
321-
NEXUS_BUILD_PROMOTION_PROFILE_ID: "${MAVEN_NEXUS_BUILD_PROMOTION_PROFILE_ID}",
322-
])
323-
}
324316
}
325317
KogitoJobTemplate.createPipelineJob(this, jobParams)?.with {
326318
parameters {

0 commit comments

Comments
 (0)