Skip to content

Commit

Permalink
[incubator-kie-issues#732] Refactor uploading artifacts to deploy rep…
Browse files Browse the repository at this point in the history
…ository

use merge-maven-repos plugin
  • Loading branch information
cimbalek authored and jstastny-cz committed Dec 5, 2023
1 parent 1e55e1b commit 078ceea
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
45 changes: 26 additions & 19 deletions .ci/jenkins/Jenkinsfile.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -158,39 +158,46 @@ pipeline {
}
}
}

stage('Deploy to repository') {
when {
expression { return !shouldStageArtifacts() && !isSpecificArtifactsUpload() && shouldDeployToRepository() }
}
steps {
script {
runMavenDeploy(getOptaplannerMavenCommand())
runMavenDeploy(getOptaplannerQuickstartsMavenCommand().withOptions(['-pl', ':optaplanner-distribution']))
}
}
}
stage('Deploy locally') {
when {
expression { return shouldStageArtifacts() || isSpecificArtifactsUpload() }
}
steps {
script {
runMavenDeploy(getOptaplannerMavenCommand(), optaplannerRepository)
}
}
}
stage('Upload artifacts to given repository') {
stage('Deploy to repository') {
when {
expression { return isSpecificArtifactsUpload() }
expression { return shouldDeployToRepository() }
}
steps {
script {
// Deploy to specific repository with credentials
maven.uploadLocalArtifacts(env.MAVEN_REPO_CREDS_ID, getLocalDeploymentFolder(optaplannerRepository), getMavenRepoZipUrl())
withCredentials([usernamePassword(credentialsId: env.MAVEN_REPO_CREDS_ID, usernameVariable: 'REPOSITORY_USER', passwordVariable: 'REPOSITORY_TOKEN')]) {
configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]) {
new MavenCommand(this)
.withSettingsXmlFile(MAVEN_SETTINGS_FILE)
.withProperty('wagon.source', "file://${getLocalDeploymentFolder(optaplannerRepository)}")
.withProperty('wagon.target', MAVEN_DEPLOY_REPOSITORY)
.withProperty('wagon.targetId', 'apache-snapshots-repository')
.withProperty('apache.snapshot.repository.username', REPOSITORY_USER)
.withProperty('apache.snapshot.repository.password', REPOSITORY_TOKEN)
.run("org.codehaus.mojo:wagon-maven-plugin:2.0.2:merge-maven-repos")
}
}
}
}
}

// stage('Upload artifacts to given repository') {
// when {
// expression { return isSpecificArtifactsUpload() }
// }
// steps {
// script {
// // Deploy to specific repository with credentials
// maven.uploadLocalArtifacts(env.MAVEN_REPO_CREDS_ID, getLocalDeploymentFolder(optaplannerRepository), getMavenRepoZipUrl())
// }
// }
// }
stage('Stage artifacts') {
when {
expression { return shouldStageArtifacts() }
Expand Down
4 changes: 3 additions & 1 deletion .ci/jenkins/dsl/jobs.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,9 @@ void setupDeployJob(JobType jobType, String envName = '') {
GIT_AUTHOR_PUSH_CREDS_ID: "${GIT_AUTHOR_PUSH_CREDENTIALS_ID}",

MAVEN_DEPENDENCIES_REPOSITORY: "${MAVEN_ARTIFACTS_REPOSITORY}",
MAVEN_DEPLOY_REPOSITORY: "${MAVEN_ARTIFACTS_REPOSITORY}",

MAVEN_DEPLOY_REPOSITORY: "${MAVEN_ARTIFACTS_UPLOAD_REPOSITORY_URL}",
MAVEN_REPO_CREDS_ID: "${MAVEN_ARTIFACTS_UPLOAD_REPOSITORY_CREDS_ID}",

OPERATOR_IMAGE_NAME: 'optaplanner-operator',
MAX_REGISTRY_RETRIES: 3,
Expand Down

0 comments on commit 078ceea

Please sign in to comment.