Skip to content

Commit

Permalink
PLANNER-2877 Support 9.x in the CI
Browse files Browse the repository at this point in the history
  • Loading branch information
rsynek committed Jan 30, 2023
1 parent 0a73edb commit 397aef3
Show file tree
Hide file tree
Showing 6 changed files with 193 additions and 33 deletions.
90 changes: 70 additions & 20 deletions .ci/jenkins/Jenkinsfile.deploy
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import org.jenkinsci.plugins.workflow.libs.Library
@Library('jenkins-pipeline-shared-libraries')_

@Library('jenkins-pipeline-shared-libraries') _

import org.kie.jenkins.MavenCommand
import org.kie.jenkins.MavenStagingHelper
Expand Down Expand Up @@ -84,20 +85,30 @@ pipeline {

stage('Clone repositories') {
steps {
checkoutRepo(optaplannerRepository)
checkoutQuickstarts()
checkoutRepo(vehicleRoutingRepository)
script {
checkoutRepo(optaplannerRepository)
// TODO: switch to the 9 stream after quickstarts and the optaweb will have been migrated.
if (isStream8()) {
checkoutQuickstarts()
checkoutRepo(vehicleRoutingRepository)
}
}
}
}

stage('Prepare for PR') {
when {
expression { return isRelease() || isCreatePr() }
expression { return isRelease() || isCreatePr() }
}
steps {
prepareForPR(optaplannerRepository)
prepareForPR(vehicleRoutingRepository)
prepareForPR(quickstartsRepository)
script {
prepareForPR(optaplannerRepository)
// TODO: switch to the 9 stream after quickstarts and the optaweb will have been migrated.
if (isStream8()) {
prepareForPR(vehicleRoutingRepository)
prepareForPR(quickstartsRepository)
}
}
}
}

Expand All @@ -115,9 +126,12 @@ pipeline {

mavenCleanInstallOptaPlannerParents()

maven.mvnVersionsUpdateParentAndChildModules(getOptawebVehicleRoutingMavenCommand(), getProjectVersion(), !isRelease())
// TODO: switch to the 9 stream after quickstarts and the optaweb will have been migrated.
if (isStream8()) {
maven.mvnVersionsUpdateParentAndChildModules(getOptawebVehicleRoutingMavenCommand(), getProjectVersion(), !isRelease())

updateQuickstartsVersions()
updateQuickstartsVersions()
}
}
}
}
Expand Down Expand Up @@ -146,9 +160,16 @@ pipeline {
}

stage('Build Quickstarts') {
when {
// TODO: switch to the 9 stream after quickstarts and the optaweb will have been migrated.
expression { return isStream8() }
}
steps {
script {
getOptaplannerQuickstartsMavenCommand().withProperty('maven.test.failure.ignore', true).skipTests(params.SKIP_TESTS).run('clean install')
getOptaplannerQuickstartsMavenCommand()
.withProperty('maven.test.failure.ignore', true)
.skipTests(params.SKIP_TESTS)
.run('clean install')
}
}
post {
Expand All @@ -162,6 +183,10 @@ pipeline {
}

stage('Build Vehicle Routing') {
when {
// TODO: switch to the 9 stream after quickstarts and the optaweb will have been migrated.
expression { return isStream8() }
}
steps {
script {
buildOptaweb(getOptawebVehicleRoutingMavenCommand())
Expand All @@ -185,8 +210,11 @@ pipeline {
steps {
script {
runMavenDeploy(getOptaplannerMavenCommand())
runMavenDeploy(getOptaplannerQuickstartsMavenCommand().withOptions(['-pl', ':optaplanner-distribution']))
runMavenDeploy(getOptawebVehicleRoutingMavenCommand())
// TODO: switch to the 9 stream after quickstarts and the optaweb will have been migrated.
if (isStream8()) {
runMavenDeploy(getOptaplannerQuickstartsMavenCommand().withOptions(['-pl', ':optaplanner-distribution']))
runMavenDeploy(getOptawebVehicleRoutingMavenCommand())
}
}
}
}
Expand All @@ -197,7 +225,10 @@ pipeline {
steps {
script {
runMavenDeploy(getOptaplannerMavenCommand(), optaplannerRepository)
runMavenDeploy(getOptawebVehicleRoutingMavenCommand(), vehicleRoutingRepository)
// TODO: switch to the 9 stream after quickstarts and the optaweb will have been migrated.
if (isStream8()) {
runMavenDeploy(getOptawebVehicleRoutingMavenCommand(), vehicleRoutingRepository)
}
}
}
}
Expand All @@ -209,7 +240,10 @@ pipeline {
script {
// Deploy to specific repository with credentials
maven.uploadLocalArtifacts(env.MAVEN_REPO_CREDS_ID, getLocalDeploymentFolder(optaplannerRepository), getMavenRepoZipUrl())
maven.uploadLocalArtifacts(env.MAVEN_REPO_CREDS_ID, getLocalDeploymentFolder(vehicleRoutingRepository), getMavenRepoZipUrl())
// TODO: switch to the 9 stream after quickstarts and the optaweb will have been migrated.
if (isStream8()) {
maven.uploadLocalArtifacts(env.MAVEN_REPO_CREDS_ID, getLocalDeploymentFolder(vehicleRoutingRepository), getMavenRepoZipUrl())
}
}
}
}
Expand All @@ -221,7 +255,10 @@ pipeline {
script {
// Stage release artifacts
runMavenStage(getOptaplannerMavenCommand(), optaplannerRepository)
runMavenStage(getOptawebVehicleRoutingMavenCommand(), vehicleRoutingRepository)
// TODO: switch to the 9 stream after quickstarts and the optaweb will have been migrated.
if (isStream8()) {
runMavenStage(getOptawebVehicleRoutingMavenCommand(), vehicleRoutingRepository)
}
}
}
}
Expand All @@ -231,9 +268,14 @@ pipeline {
expression { return isRelease() || isCreatePr() }
}
steps {
commitAndCreatePR(optaplannerRepository, getBuildBranch())
commitAndCreatePRIgnoringNpmRegistry(vehicleRoutingRepository, getBuildBranch())
commitAndCreatePR(quickstartsRepository, getQuickStartsBranch())
script {
commitAndCreatePR(optaplannerRepository, getBuildBranch())
// TODO: switch to the 9 stream after quickstarts and the optaweb will have been migrated.
if (isStream8()) {
commitAndCreatePRIgnoringNpmRegistry(vehicleRoutingRepository, getBuildBranch())
commitAndCreatePR(quickstartsRepository, getQuickStartsBranch())
}
}
}
post {
success {
Expand All @@ -254,7 +296,7 @@ pipeline {

stage('Push a temporary operator image to a registry') {
when {
expression { return isRelease() }
expression { return isRelease() && isStream8() }
}
steps {
script {
Expand Down Expand Up @@ -589,4 +631,12 @@ void pushOperatorTemporaryImage() {
getOperatorImageNamespace(), getOperatorImageName(), temporaryImageTag)
imageUtils.tagImage(localImage, temporaryImageFullName)
imageUtils.pushImage(temporaryImageFullName)
}

boolean isStream8() {
return env.OPTAPLANNER_LATEST_STREAM == '8'
}

boolean isStream9() {
return env.OPTAPLANNER_LATEST_STREAM == '9'
}
39 changes: 30 additions & 9 deletions .ci/jenkins/Jenkinsfile.promote
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ pipeline {

stage('Merge Optaweb Vehicle Routing deploy PR and tag') {
when {
expression { return isRelease() }
// TODO: switch to the 9 stream after optaweb will have been migrated.
expression { return isRelease() && isStream8() }
}
steps {
script {
Expand All @@ -97,7 +98,8 @@ pipeline {

stage('Merge OptaPlanner Quickstarts PR and tag') {
when {
expression { return isRelease() }
// TODO: switch to the 9 stream after quickstarts and the optaweb will have been migrated.
expression { return isRelease() && isStream8() }
}
steps {
script {
Expand All @@ -112,23 +114,32 @@ pipeline {

stage('Upload OptaPlanner documentation') {
when {
expression { return isRelease() }
// TODO: switch to the 9 stream after quickstarts and the optaweb will have been migrated.
expression { return isRelease() && isStream8() }
}
steps {
script {
getMavenCommand().inDirectory(optaplannerRepository).skipTests(true).withProperty('full').run('clean install')
getMavenCommand()
.inDirectory(optaplannerRepository)
.skipTests(true)
.withProperty('full')
.run('clean install')
uploadDistribution(optaplannerRepository)
}
}
}

stage('Upload Vehicle Routing documentation and distribution') {
when {
expression { return isRelease() }
// TODO: switch to the 9 stream after quickstarts and the optaweb will have been migrated.
expression { return isRelease() && isStream8() }
}
steps {
script {
getMavenCommand().inDirectory(vehicleRoutingRepository).skipTests(true).run('clean install')
getMavenCommand()
.inDirectory(vehicleRoutingRepository)
.skipTests(true)
.run('clean install')
uploadDistribution(vehicleRoutingRepository)
}
}
Expand Down Expand Up @@ -162,7 +173,8 @@ pipeline {

stage('Set Optaweb Vehicle Routing next snapshot version') {
when {
expression { return isRelease() }
// TODO: switch to the 9 stream after quickstarts and the optaweb will have been migrated.
expression { return isRelease() && isStream8() }
}
steps {
script {
Expand All @@ -185,7 +197,8 @@ pipeline {

stage('Set Quickstarts next snapshot version') {
when {
expression { return isRelease() }
// TODO: switch to the 9 stream after quickstarts and the optaweb will have been migrated.
expression { return isRelease() && isStream8() }
}
steps {
script {
Expand All @@ -208,7 +221,7 @@ pipeline {

stage('Push the final OptaPlanner operator image') {
when {
expression { return isRelease() }
expression { return isRelease() && isStream8() }
}
steps {
script {
Expand Down Expand Up @@ -497,4 +510,12 @@ void removeOperatorImageTemporaryTag() {
error "Cannot remove the OptaPlanner Operator temporary image tag (${temporaryImageName}) from quay.io. "
+ "The tag should be removed manually."
}
}

boolean isStream8() {
return env.OPTAPLANNER_LATEST_STREAM == '8'
}

boolean isStream9() {
return env.OPTAPLANNER_LATEST_STREAM == '9'
}
24 changes: 22 additions & 2 deletions .ci/jenkins/dsl/jobs.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ void createProjectSetupBranchJob() {
GIT_BRANCH_NAME: "${GIT_BRANCH}",
GIT_AUTHOR: "${GIT_AUTHOR_NAME}",

IS_MAIN_BRANCH: "${Utils.isMainBranch(this)}"
IS_MAIN_BRANCH: "${Utils.isMainBranch(this)}",
OPTAPLANNER_LATEST_STREAM: getOptaPlannerLatestStream()
])
KogitoJobTemplate.createPipelineJob(this, jobParams)?.with {
parameters {
Expand All @@ -84,9 +85,11 @@ void setupProjectNightlyJob() {

GIT_BRANCH_NAME: "${GIT_BRANCH}",
GIT_AUTHOR: "${GIT_AUTHOR_NAME}",
AUTHOR_CREDS_ID: "${GIT_AUTHOR_CREDENTIALS_ID}",

MAVEN_SETTINGS_CONFIG_FILE_ID: "${MAVEN_SETTINGS_FILE_ID}",
ARTIFACTS_REPOSITORY: "${MAVEN_ARTIFACTS_REPOSITORY}",
OPTAPLANNER_LATEST_STREAM: getOptaPlannerLatestStream()
])
KogitoJobTemplate.createPipelineJob(this, jobParams)?.with {
parameters {
Expand All @@ -105,6 +108,7 @@ void setupProjectReleaseJob() {

DEFAULT_STAGING_REPOSITORY: "${MAVEN_NEXUS_STAGING_PROFILE_URL}",
ARTIFACTS_REPOSITORY: "${MAVEN_ARTIFACTS_REPOSITORY}",
OPTAPLANNER_LATEST_STREAM: getOptaPlannerLatestStream()
])
KogitoJobTemplate.createPipelineJob(this, jobParams)?.with {
parameters {
Expand Down Expand Up @@ -135,6 +139,7 @@ void setupProjectPostReleaseJob() {
MAVEN_DEPENDENCIES_REPOSITORY: "${MAVEN_ARTIFACTS_REPOSITORY}",

GITHUB_CLI_VERSION: '0.11.1',
OPTAPLANNER_LATEST_STREAM: getOptaPlannerLatestStream()
])
KogitoJobTemplate.createPipelineJob(this, jobParams)?.with {
parameters {
Expand Down Expand Up @@ -245,7 +250,8 @@ void createSetupBranchJob() {
MAVEN_DEPENDENCIES_REPOSITORY: "${MAVEN_ARTIFACTS_REPOSITORY}",
MAVEN_DEPLOY_REPOSITORY: "${MAVEN_ARTIFACTS_REPOSITORY}",

IS_MAIN_BRANCH: "${Utils.isMainBranch(this)}"
IS_MAIN_BRANCH: "${Utils.isMainBranch(this)}",
OPTAPLANNER_LATEST_STREAM: getOptaPlannerLatestStream()
])
KogitoJobTemplate.createPipelineJob(this, jobParams)?.with {
parameters {
Expand Down Expand Up @@ -273,6 +279,7 @@ void setupDeployJob(Folder jobFolder) {

JENKINS_EMAIL_CREDS_ID: "${JENKINS_EMAIL_CREDS_ID}",
MAVEN_SETTINGS_CONFIG_FILE_ID: "${MAVEN_SETTINGS_FILE_ID}",
OPTAPLANNER_LATEST_STREAM: getOptaPlannerLatestStream()
])
if (jobFolder.isPullRequest()) {
jobParams.env.putAll([
Expand Down Expand Up @@ -358,6 +365,7 @@ void setupPromoteJob(Folder jobFolder) {

PROPERTIES_FILE_NAME: 'deployment.properties',
GITHUB_CLI_VERSION: '0.11.1',
OPTAPLANNER_LATEST_STREAM: getOptaPlannerLatestStream()
])
KogitoJobTemplate.createPipelineJob(this, jobParams)?.with {
parameters {
Expand Down Expand Up @@ -398,3 +406,15 @@ void setupOptaPlannerTurtleTestsJob(String constraintStreamImplType) {
}
}
}

String getOptaPlannerLatestStream() {
String gitMainBranch = "${GIT_MAIN_BRANCH}"

if (gitMainBranch == 'main') {
return '8'
} else if (gitMainBranch == '9.x') {
return '9'
} else {
return gitMainBranch
}
}
Loading

0 comments on commit 397aef3

Please sign in to comment.