From d5d176bd2f78dbaa65c26ec23f8e3b1da71cb800 Mon Sep 17 00:00:00 2001 From: Andrea Lamparelli Date: Mon, 8 May 2023 15:17:25 +0200 Subject: [PATCH 1/7] [BXMSPROD-2019] update build-chain config --- dsl/config/branch.yaml | 1 + .../jenkinsfiles/Jenkinsfile.prod.prepare | 77 ++++++++++++++++++- dsl/seed/jobs/root_jobs.groovy | 2 + 3 files changed, 77 insertions(+), 3 deletions(-) diff --git a/dsl/config/branch.yaml b/dsl/config/branch.yaml index dc206e17f..1e376bcec 100644 --- a/dsl/config/branch.yaml +++ b/dsl/config/branch.yaml @@ -109,6 +109,7 @@ git: buildchain_config: git: repository: kogito-pipelines + path: .ci/pull-request-config.yaml maven: settings_file_id: kogito_release_settings nexus: diff --git a/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare b/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare index b6fc8f7f3..fc9b41ad6 100644 --- a/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare +++ b/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare @@ -7,6 +7,7 @@ import java.util.regex.Pattern // 1. _RELEASE_BRANCH // 2. QUARKUS_VERSION // 3. ADDITIONAL_BUILD_MAVEN_OPTS +// 4. PROJECTS_TO_REMOVE_FROM_PR_CHECKS seedConfig = [:] mainBranchConfig = [:] @@ -133,6 +134,38 @@ pipeline{ sh "rm -f ${branchConfigFilePath}" writeYaml file: "${branchConfigFilePath}", data: branchConfig, overwrite: true + // update GHA build-chain configuration + // comment out projects we are not interested in from the buildchain-config.yaml + def projectToRemoveFromBCPRChecks = getProjectsToRemoveFromBuildChainConfig() + + if (projectToRemoveFromBCPRChecks && projectToRemoveFromBCPRChecks.size() > 0) { + // update build-chain config + def buildChainConfigFilePath = readMainBranchConfig().buildchain_config.git.path + def buildChainConfig = readYaml file: buildChainConfigFilePath + + def builds = buildChainConfig.build.findAll { build -> + !projectToRemoveFromBCPRChecks.contains(build.project) + } + buildChainConfig.build = builds + + echo "Write build-chain configuration => ${buildChainConfig}" + sh "rm -f ${buildChainConfigFilePath}" + writeYaml file: "${buildChainConfigFilePath}", data: buildChainConfig, overwrite: true + + // update build-chain project dependencies + def buildChainConfigDependenciesFilePath = buildChainConfigFilePath.substring(0, buildChainConfigFilePath.lastIndexOf('/') + 1) + "${buildChainConfig.dependencies}" + def buildChainConfigDependencies = readYaml file: buildChainConfigDependenciesFilePath + + def deps = buildChainConfigDependencies.dependencies.findAll { dep -> + !projectToRemoveFromBCPRChecks.contains(dep.project) + } + buildChainConfigDependencies.dependencies = deps + + echo "Write build-chain dependencies configuration => ${buildChainConfigDependencies}" + sh "rm -f ${buildChainConfigDependenciesFilePath}" + writeYaml file: "${buildChainConfigDependenciesFilePath}", data: buildChainConfigDependencies, overwrite: true + } + pushIfChanged(prodBranch, getMainBranchConfigFileGitAuthorCredentialsId(), "Setup DSL branch config after productized branch creation", "Branch config on ${prodBranch} has been updated with correct configuration") } } @@ -149,9 +182,12 @@ pipeline{ // stage("Update prod branch for all projects to be productized"){ // steps{ - // script { - // // TODO: implement - // } + // script { + // def prodRepositories = getProdRepositoriesToBranch() + // prodRepositories.each { repo -> + // updateProductizedBranch(repo.name) + // } + // } // } // } @@ -216,6 +252,10 @@ def getAdditionalDefaultBuildMavenOpts() { return params.ADDITIONAL_BUILD_MAVEN_OPTS ?: '' } +def getProjectsToRemoveFromBuildChainConfig() { + return params.PROJECTS_TO_REMOVE_FROM_PR_CHECKS.split(',') as List ?: [] +} + // Retrieve seed configuration String checkoutMainSeedConfigFileRepo() { @@ -404,6 +444,37 @@ String getBranchConfigProductizedBranch() { return (getProdRepositoriesToBranch().find { it -> it.is_branch_config_repo }?.branch) ?: "${getEcosystemMainProject()}-${getEcosystemProductizedBranch()}" } +// Update productized branch on all projects to be productized + +// - disable PR checks from jobs.groovy +// - disable GHA jobs no more needed by commenting out workflows +// - enable productized profile (-Dproductized) on GHA PR checks workflows +// - ensure that fullProfile is not enabled on .ci/jenkins/dsl/jobs.groovy, if so remove it +// def updateProductizedBranch(String repository) { +// def repoConfig = getProdRepositoriesToBranch().find { it -> it.name.equalsIgnoreCase(repository) } +// assert repoConfig : "Cannot find repo ${repository} in the productized list" + +// String repoAuthor = repoConfig.author?.name ?: readMainBranchConfig().git.author.name +// String repoCredsId = repoConfig.author?.credentials_id ?: readMainBranchConfig().git.author.credentials_id + +// // TODO is this value saved somewhere such that we do not have to hardcode? +// String jobsGroovyPath = '.ci/jenkins/dsl/jobs.groovy' + +// dir(repository) { +// deleteDir() +// // here productized branches should have been already created on repos to be productized +// checkout(githubscm.resolveRepository(repository, repoAuthor, getProductizedBranchFromRepository(repository), false, repoCredsId)) + +// getOrCreateGitBranch(repoConfig.branch, getRepositoryAuthorCredsId()) + +// // TODO: check if file exist otherwise, skip it with warning +// def jobsGroovy = readFile file: jobsGroovyPath +// // TODO: update jobs.groovy + +// sh 'ls -la' +// } +// } + // Git utilities void getOrCreateGitBranch(String branch, String credentialsId) { diff --git a/dsl/seed/jobs/root_jobs.groovy b/dsl/seed/jobs/root_jobs.groovy index b3d88f96d..efa8c8694 100644 --- a/dsl/seed/jobs/root_jobs.groovy +++ b/dsl/seed/jobs/root_jobs.groovy @@ -112,6 +112,8 @@ if (communityReleaseBranches) { stringParam('QUARKUS_VERSION', '', 'Quarkus version to which to update all productized branches, usually latest LTS version') stringParam('ADDITIONAL_BUILD_MAVEN_OPTS', '', 'Additional default maven opts for jenkins jobs, e.g., -Ddata-index-ephemeral.image=quay.io/kiegroup/kogito-data-index-ephemeral') + stringParam('PROJECTS_TO_REMOVE_FROM_PR_CHECKS', '', 'Comma-separated list of projects (/) to be removed/disabled from build chain pull request config') + booleanParam('DRY_RUN', false, 'If enabled no changes will be applied to remote branches') } From 0e4d0f9dc44c6e262bdd1ad960e5d67f6fc7b468 Mon Sep 17 00:00:00 2001 From: Andrea Lamparelli Date: Tue, 9 May 2023 11:25:29 +0200 Subject: [PATCH 2/7] [BXMSPROD-2019] Update prod branch and downgrade quarkus --- .../jenkinsfiles/Jenkinsfile.prod.prepare | 165 ++++++++++++------ dsl/seed/jobs/root_jobs.groovy | 2 +- 2 files changed, 116 insertions(+), 51 deletions(-) diff --git a/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare b/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare index fc9b41ad6..2f836f47f 100644 --- a/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare +++ b/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare @@ -6,8 +6,9 @@ import java.util.regex.Pattern // parameters // 1. _RELEASE_BRANCH // 2. QUARKUS_VERSION -// 3. ADDITIONAL_BUILD_MAVEN_OPTS -// 4. PROJECTS_TO_REMOVE_FROM_PR_CHECKS +// 3. DOWNGRADE_PR_BRANCH +// 4. ADDITIONAL_BUILD_MAVEN_OPTS +// 5. PROJECTS_TO_REMOVE_FROM_PR_CHECKS seedConfig = [:] mainBranchConfig = [:] @@ -179,30 +180,107 @@ pipeline{ // - disable GHA jobs no more needed by commenting out workflows // - enable productized profile (-Dproductized) on GHA PR checks workflows // - ensure that fullProfile is not enabled on .ci/jenkins/dsl/jobs.groovy, if so remove it + stage("Update prod branch for all projects to be productized"){ + steps{ + script { + def prodRepositories = getProdRepositoriesToBranch() + prodRepositories.each { repoConfig -> + String repository = repoConfig.name + String repoAuthor = repoConfig.author?.name ?: readMainBranchConfig().git.author.name + String repoCredsId = repoConfig.author?.credentials_id ?: readMainBranchConfig().git.author.credentials_id + + // TODO is this value saved somewhere such that we do not have to hardcode? + String jobsGroovyPath = '.ci/jenkins/dsl/jobs.groovy' + + dir(repository) { + deleteDir() + // here productized branches should have been already created on repos to be productized + checkout(githubscm.resolveRepository(repository, repoAuthor, getProductizedBranchFromRepository(repository), false, repoCredsId)) + + getOrCreateGitBranch(repoConfig.branch, getRepositoryAuthorCredsId()) + + if (fileExists("${jobsGroovyPath}")) { + // def jobsGroovy = readFile file: jobsGroovyPath + // remove fullProfile + sh "sed -i 's/, addFullProfileJobParamsGetter)/)/g' ${jobsGroovyPath}" + // TODO: disable pr checks in getMultijobPRConfig, get them from params + } else { + echo "[WARN] Unable to find jobs.groovy for '${repository}' at '${jobsGroovyPath}'" + } + - // stage("Update prod branch for all projects to be productized"){ - // steps{ - // script { - // def prodRepositories = getProdRepositoriesToBranch() - // prodRepositories.each { repo -> - // updateProductizedBranch(repo.name) - // } - // } - // } - // } + // TODO iterate over PR workflows + // - comment out if not needed (get these from param?) + // - if PR check is needed, keep it and add -Dproductized + } + } + } + } + } // 3. call update quarkus job in order to downgrade quarkus to LTS version (version provided as parameter QUARKUS_VERSION) // this will: // - downgrade quarkus, there already exists a job doing this // - apply patches from .ci/environments/quarkus-lts on the same PR - // stage('Downgrade quarkus to LTS version'){ - // steps{ - // script { - // // TODO: implement - // } - // } - // } + stage('Downgrade quarkus to LTS version'){ + when { + expression { return params.QUARKUS_VERSION } + } + steps{ + script { + println "Launch update quarkus all" + + String jobName = "${getEcosystemProductizedBranch()}/tools/update-quarkus-all" + String quarkusDowngradePrBranch = getQuarkusDowngradePrBranch() + List jobParams = [] + jobParams.add(stringParam(name: 'NEW_VERSION', value: getQuarkusVersion())) + jobParams.add(stringParam(name: 'PR_BRANCH', value: quarkusDowngradePrBranch)) + + echo "Build ./${jobName} with parameters ${jobParams}" + if (!isDryRun()) { + def job = build(job: "./${jobName}", parameters: jobParams, wait: true, propagate: false) + + if (job.result == 'SUCCESS') { + def prodRepositories = getProdRepositoriesToBranch() + prodRepositories.each { repoConfig -> + String repoAuthor = repoConfig.author?.name ?: readMainBranchConfig().git.author.name + String repoCredsId = repoConfig.author?.credentials_id ?: readMainBranchConfig().git.author.credentials_id + String repository = repoConfig.name + String baseBranch = repoConfig.branch ?: 'main' + + // FIXME apply patches only if the quarkusDowngradePrBranch already exist, otherwise skip it + + dir(repository) { + deleteDir() + checkout(githubscm.resolveRepository(repository, repoAuthor, baseBranch, false, repoCredsId)) + + // if quarkusDowngradePrBranch has been created by update-quarkus-all job, checkout it + if (checkoutGitBranchIfExists(quarkusDowngradePrBranch, repoCredsId)) { + // apply patches from .ci/environments/quarkus-lts/patches + def patchesDirectory = '.ci/environments/quarkus-lts/patches' + def patches = findFiles(glob: "${patchesDirectory}/*") + + if (patches && patches.size() > 0) { + patches.each { patch -> + echo "Applying patch ${patch}" + sh "git apply ${patch}" + } + } else { + echo "No patches found at ${patchesDirectory}" + } + + pushIfChanged(quarkusDowngradePrBranch, repoCredsId, "Applied patches after Quarkus downgrade to ${getQuarkusVersion()}", "Quarkus LTS patches on ${quarkusDowngradePrBranch} have been applied") + } + } + } + } else { + unstable("Update Quarkus on repositories was not successful") + } + } + } + } + } } post{ unsuccessful { @@ -243,6 +321,10 @@ String getQuarkusVersion() { return params.QUARKUS_VERSION } +String getQuarkusDowngradePrBranch() { + return params.DOWNGRADE_PR_BRANCH ?: "${getEcosystemProductizedBranch()}-${getQuarkusVersion()}-downgrade" +} + Boolean isDryRun() { return params.DRY_RUN } @@ -444,37 +526,6 @@ String getBranchConfigProductizedBranch() { return (getProdRepositoriesToBranch().find { it -> it.is_branch_config_repo }?.branch) ?: "${getEcosystemMainProject()}-${getEcosystemProductizedBranch()}" } -// Update productized branch on all projects to be productized - -// - disable PR checks from jobs.groovy -// - disable GHA jobs no more needed by commenting out workflows -// - enable productized profile (-Dproductized) on GHA PR checks workflows -// - ensure that fullProfile is not enabled on .ci/jenkins/dsl/jobs.groovy, if so remove it -// def updateProductizedBranch(String repository) { -// def repoConfig = getProdRepositoriesToBranch().find { it -> it.name.equalsIgnoreCase(repository) } -// assert repoConfig : "Cannot find repo ${repository} in the productized list" - -// String repoAuthor = repoConfig.author?.name ?: readMainBranchConfig().git.author.name -// String repoCredsId = repoConfig.author?.credentials_id ?: readMainBranchConfig().git.author.credentials_id - -// // TODO is this value saved somewhere such that we do not have to hardcode? -// String jobsGroovyPath = '.ci/jenkins/dsl/jobs.groovy' - -// dir(repository) { -// deleteDir() -// // here productized branches should have been already created on repos to be productized -// checkout(githubscm.resolveRepository(repository, repoAuthor, getProductizedBranchFromRepository(repository), false, repoCredsId)) - -// getOrCreateGitBranch(repoConfig.branch, getRepositoryAuthorCredsId()) - -// // TODO: check if file exist otherwise, skip it with warning -// def jobsGroovy = readFile file: jobsGroovyPath -// // TODO: update jobs.groovy - -// sh 'ls -la' -// } -// } - // Git utilities void getOrCreateGitBranch(String branch, String credentialsId) { @@ -492,6 +543,20 @@ void getOrCreateGitBranch(String branch, String credentialsId) { } } +// If the provided branch exists, checkout it and return true, otherwise return false and skip checkout. +boolean checkoutGitBranchIfExists(String branch, String credentialsId) { + sh 'git fetch origin' + String branchRemoteResult = sh(script: "git ls-remote origin ${branch} | wc -l", returnStdout: true).trim() + if (Integer.parseInt(branchRemoteResult) > 0) { + echo "Branch ${branch} exist. Checking out !" + sh "git checkout ${branch}" + return true + } + + echo "Branch ${branch} does not exist... skipping checkout" + return false +} + def pushIfChanged(String branch, String credentialsId, String commitMsg, String notificationMsg) { if (githubscm.isThereAnyChanges()) { sh 'git diff' diff --git a/dsl/seed/jobs/root_jobs.groovy b/dsl/seed/jobs/root_jobs.groovy index efa8c8694..2c4022751 100644 --- a/dsl/seed/jobs/root_jobs.groovy +++ b/dsl/seed/jobs/root_jobs.groovy @@ -110,8 +110,8 @@ if (communityReleaseBranches) { } stringParam('QUARKUS_VERSION', '', 'Quarkus version to which to update all productized branches, usually latest LTS version') + stringParam('DOWNGRADE_PR_BRANCH', '', 'Which PR branch name to use for Quarkus downgrade? If none given, a name will be generated automatically.') stringParam('ADDITIONAL_BUILD_MAVEN_OPTS', '', 'Additional default maven opts for jenkins jobs, e.g., -Ddata-index-ephemeral.image=quay.io/kiegroup/kogito-data-index-ephemeral') - stringParam('PROJECTS_TO_REMOVE_FROM_PR_CHECKS', '', 'Comma-separated list of projects (/) to be removed/disabled from build chain pull request config') booleanParam('DRY_RUN', false, 'If enabled no changes will be applied to remote branches') From 139ba2ad03820402bb77d7a94f3b8db8c8e87373 Mon Sep 17 00:00:00 2001 From: Andrea Lamparelli Date: Tue, 9 May 2023 11:31:01 +0200 Subject: [PATCH 3/7] fix path to file_path on branch.yaml --- dsl/config/branch.yaml | 2 +- dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dsl/config/branch.yaml b/dsl/config/branch.yaml index 1e376bcec..ed6f41fb7 100644 --- a/dsl/config/branch.yaml +++ b/dsl/config/branch.yaml @@ -109,7 +109,7 @@ git: buildchain_config: git: repository: kogito-pipelines - path: .ci/pull-request-config.yaml + file_path: .ci/pull-request-config.yaml maven: settings_file_id: kogito_release_settings nexus: diff --git a/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare b/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare index 2f836f47f..1b616b94a 100644 --- a/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare +++ b/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare @@ -141,7 +141,7 @@ pipeline{ if (projectToRemoveFromBCPRChecks && projectToRemoveFromBCPRChecks.size() > 0) { // update build-chain config - def buildChainConfigFilePath = readMainBranchConfig().buildchain_config.git.path + def buildChainConfigFilePath = readMainBranchConfig().buildchain_config.git.file_path def buildChainConfig = readYaml file: buildChainConfigFilePath def builds = buildChainConfig.build.findAll { build -> From 50c896727a43d15dc4df07302a8fad7e7f6d497b Mon Sep 17 00:00:00 2001 From: Andrea Lamparelli Date: Mon, 5 Jun 2023 12:55:03 +0200 Subject: [PATCH 4/7] Trigger setup-branch job to update versions --- .ci/jenkins/Jenkinsfile.setup-branch | 3 ++ .ci/jenkins/dsl/jobs.groovy | 1 + .../jenkinsfiles/Jenkinsfile.prod.prepare | 44 ++++++++++++++++--- dsl/seed/jobs/root_jobs.groovy | 7 +++ 4 files changed, 50 insertions(+), 5 deletions(-) diff --git a/.ci/jenkins/Jenkinsfile.setup-branch b/.ci/jenkins/Jenkinsfile.setup-branch index 5988c9728..3d718abac 100644 --- a/.ci/jenkins/Jenkinsfile.setup-branch +++ b/.ci/jenkins/Jenkinsfile.setup-branch @@ -181,6 +181,9 @@ pipeline { // Launch the nightly to deploy all artifacts from the branch stage('Launch the nightly') { + when { + return params.DEPLOY_ARTIFACTS + } steps { script { def buildParams = getDefaultBuildParams() diff --git a/.ci/jenkins/dsl/jobs.groovy b/.ci/jenkins/dsl/jobs.groovy index 48fd06bea..823cee179 100644 --- a/.ci/jenkins/dsl/jobs.groovy +++ b/.ci/jenkins/dsl/jobs.groovy @@ -119,6 +119,7 @@ void createSetupBranchJob() { parameters { stringParam('KOGITO_VERSION', '', 'Kogito version') stringParam('DROOLS_VERSION', '', 'Drools version') + booleanParam('DEPLOY_ARTIFACTS', true, 'Deploy artifacts') } } } diff --git a/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare b/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare index 1b616b94a..b95c6be62 100644 --- a/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare +++ b/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare @@ -5,10 +5,11 @@ import java.util.regex.Pattern // parameters // 1. _RELEASE_BRANCH -// 2. QUARKUS_VERSION -// 3. DOWNGRADE_PR_BRANCH -// 4. ADDITIONAL_BUILD_MAVEN_OPTS -// 5. PROJECTS_TO_REMOVE_FROM_PR_CHECKS +// 2. _UPDATE_VERSION (this includes also dependencies) +// 3. QUARKUS_VERSION +// 4. DOWNGRADE_PR_BRANCH +// 5. ADDITIONAL_BUILD_MAVEN_OPTS +// 6. PROJECTS_TO_REMOVE_FROM_PR_CHECKS seedConfig = [:] mainBranchConfig = [:] @@ -218,7 +219,36 @@ pipeline{ } } - // 3. call update quarkus job in order to downgrade quarkus to LTS version (version provided as parameter QUARKUS_VERSION) + // 3. update the projects version in order to avoid any kind of conflicts with already existing and deployed artifacts + + stage("Update projects version"){ + when { + expression { return getProjectUpdateVersionKeys().findAll{ it.value != '' } } + } + steps{ + script { + println "Updating projects versions" + + String jobName = "${getEcosystemProductizedBranch()}/setup-branch/0-setup-branch" + List jobParams = [] + jobParams.add(booleanParam(name: 'DEPLOY_ARTIFACTS', value: false)) + // here we could have a variable number of params + getProjectUpdateVersionKeys().each{ p -> + jobParams.add(stringParam(name: p.key.replace('_UPDATE', ''), value: p.value)) + } + + echo "Build ./${jobName} with parameters ${jobParams}" + if (!isDryRun()) { + def job = build(job: "./${jobName}", parameters: jobParams, wait: true, propagate: false) + if (job.result != 'SUCCESS') { + unstable("Update projects version on repositories was not successful") + } + } + } + } + } + + // 4. call update quarkus job in order to downgrade quarkus to LTS version (version provided as parameter QUARKUS_VERSION) // this will: // - downgrade quarkus, there already exists a job doing this // - apply patches from .ci/environments/quarkus-lts on the same PR @@ -317,6 +347,10 @@ String getProdBranchSuffixParameterKey(String projectName) { return params."${key}" } +def getProjectUpdateVersionKeys() { + return params.findAll{ it.key.contains('_UPDATE_VERSION') } +} + String getQuarkusVersion() { return params.QUARKUS_VERSION } diff --git a/dsl/seed/jobs/root_jobs.groovy b/dsl/seed/jobs/root_jobs.groovy index 2c4022751..aec1ab559 100644 --- a/dsl/seed/jobs/root_jobs.groovy +++ b/dsl/seed/jobs/root_jobs.groovy @@ -107,6 +107,13 @@ if (communityReleaseBranches) { PRODUCTIZED_PROJECTS.split(',').each { projectName -> choiceParam("${projectName}_RELEASE_BRANCH".toUpperCase(), communityReleaseBranches, "${Utils.getRepoNameCamelCase(projectName)} community branch to which to create the productized branch from") stringParam("${projectName}_PROD_BRANCH_SUFFIX".toUpperCase(), 'prod', "${Utils.getRepoNameCamelCase(projectName)} productized branch suffix") + stringParam("${projectName}_UPDATE_VERSION".toUpperCase(), '', "${Utils.getRepoNameCamelCase(projectName)} dependency version which this will depend on") + } + + if (DEPENDENCY_PROJECTS) { + DEPENDENCY_PROJECTS.split(',').each { projectName -> + stringParam("${projectName}_UPDATE_VERSION".toUpperCase(), '', "${Utils.getRepoNameCamelCase(projectName)} dependency version which this will depend on") + } } stringParam('QUARKUS_VERSION', '', 'Quarkus version to which to update all productized branches, usually latest LTS version') From 0a18c07c98e24b87f7f4cccf0902005a1e51f3ab Mon Sep 17 00:00:00 2001 From: Andrea Lamparelli Date: Tue, 20 Jun 2023 14:42:14 +0200 Subject: [PATCH 5/7] Apply suggestions from code review Co-authored-by: Tristan Radisson --- dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare b/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare index b95c6be62..cf6bced8e 100644 --- a/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare +++ b/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare @@ -136,11 +136,11 @@ pipeline{ sh "rm -f ${branchConfigFilePath}" writeYaml file: "${branchConfigFilePath}", data: branchConfig, overwrite: true - // update GHA build-chain configuration + // update build-chain configuration // comment out projects we are not interested in from the buildchain-config.yaml def projectToRemoveFromBCPRChecks = getProjectsToRemoveFromBuildChainConfig() - if (projectToRemoveFromBCPRChecks && projectToRemoveFromBCPRChecks.size() > 0) { + if (projectToRemoveFromBCPRChecks) { // update build-chain config def buildChainConfigFilePath = readMainBranchConfig().buildchain_config.git.file_path def buildChainConfig = readYaml file: buildChainConfigFilePath @@ -294,7 +294,7 @@ pipeline{ if (patches && patches.size() > 0) { patches.each { patch -> echo "Applying patch ${patch}" - sh "git apply ${patch}" + sh "git apply --whitespace=fix ${patch}" } } else { echo "No patches found at ${patchesDirectory}" From 42b0cf33207c30afef40735044933799aae48cc6 Mon Sep 17 00:00:00 2001 From: Andrea Lamparelli Date: Tue, 20 Jun 2023 14:53:56 +0200 Subject: [PATCH 6/7] Applied suggestions after code review --- dsl/config/branch.yaml | 1 + dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare | 12 ++++++------ dsl/seed/jobs/root_jobs.groovy | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/dsl/config/branch.yaml b/dsl/config/branch.yaml index ed6f41fb7..266a19feb 100644 --- a/dsl/config/branch.yaml +++ b/dsl/config/branch.yaml @@ -141,3 +141,4 @@ jenkins: default_tools: jdk: kie-jdk11 maven: kie-maven-3.8.7 + jobs_definition_file: .ci/jenkins/dsl/jobs.groovy diff --git a/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare b/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare index cf6bced8e..742d9ce51 100644 --- a/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare +++ b/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare @@ -7,7 +7,7 @@ import java.util.regex.Pattern // 1. _RELEASE_BRANCH // 2. _UPDATE_VERSION (this includes also dependencies) // 3. QUARKUS_VERSION -// 4. DOWNGRADE_PR_BRANCH +// 4. DOWNGRADE_QUARKUS_PR_BRANCH // 5. ADDITIONAL_BUILD_MAVEN_OPTS // 6. PROJECTS_TO_REMOVE_FROM_PR_CHECKS @@ -190,8 +190,7 @@ pipeline{ String repoAuthor = repoConfig.author?.name ?: readMainBranchConfig().git.author.name String repoCredsId = repoConfig.author?.credentials_id ?: readMainBranchConfig().git.author.credentials_id - // TODO is this value saved somewhere such that we do not have to hardcode? - String jobsGroovyPath = '.ci/jenkins/dsl/jobs.groovy' + String jobsGroovyPath = getJobDefinitionFilePath() dir(repository) { deleteDir() @@ -279,8 +278,6 @@ pipeline{ String repository = repoConfig.name String baseBranch = repoConfig.branch ?: 'main' - // FIXME apply patches only if the quarkusDowngradePrBranch already exist, otherwise skip it - dir(repository) { deleteDir() checkout(githubscm.resolveRepository(repository, repoAuthor, baseBranch, false, repoCredsId)) @@ -356,7 +353,7 @@ String getQuarkusVersion() { } String getQuarkusDowngradePrBranch() { - return params.DOWNGRADE_PR_BRANCH ?: "${getEcosystemProductizedBranch()}-${getQuarkusVersion()}-downgrade" + return params.DOWNGRADE_QUARKUS_PR_BRANCH ?: "${getEcosystemProductizedBranch()}-${getQuarkusVersion()}-downgrade" } Boolean isDryRun() { @@ -431,6 +428,9 @@ String getRepoNameCamelCase(String repo) { return words.collect { it.isEmpty() ? it : it.substring(0, 1).toUpperCase() + it.substring(1).toLowerCase() }.join(' ') } +String getJobDefinitionFilePath() { + return readMainBranchConfig().jenkins?.jobs_definition_file ?: '.ci/jenkins/dsl/jobs.groovy' +} // Retrieve impacted projects diff --git a/dsl/seed/jobs/root_jobs.groovy b/dsl/seed/jobs/root_jobs.groovy index aec1ab559..d170f6032 100644 --- a/dsl/seed/jobs/root_jobs.groovy +++ b/dsl/seed/jobs/root_jobs.groovy @@ -117,7 +117,7 @@ if (communityReleaseBranches) { } stringParam('QUARKUS_VERSION', '', 'Quarkus version to which to update all productized branches, usually latest LTS version') - stringParam('DOWNGRADE_PR_BRANCH', '', 'Which PR branch name to use for Quarkus downgrade? If none given, a name will be generated automatically.') + stringParam('DOWNGRADE_QUARKUS_PR_BRANCH', '', 'Which PR branch name to use for Quarkus downgrade? If none given, a name will be generated automatically.') stringParam('ADDITIONAL_BUILD_MAVEN_OPTS', '', 'Additional default maven opts for jenkins jobs, e.g., -Ddata-index-ephemeral.image=quay.io/kiegroup/kogito-data-index-ephemeral') stringParam('PROJECTS_TO_REMOVE_FROM_PR_CHECKS', '', 'Comma-separated list of projects (/) to be removed/disabled from build chain pull request config') From ac058b2e040f2f5b890dff21ae426bb94d06b5c0 Mon Sep 17 00:00:00 2001 From: Andrea Lamparelli Date: Tue, 20 Jun 2023 15:05:22 +0200 Subject: [PATCH 7/7] applying patches running .ci/environments/update.sh script --- dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare b/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare index 742d9ce51..7ef1c6f43 100644 --- a/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare +++ b/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare @@ -284,18 +284,9 @@ pipeline{ // if quarkusDowngradePrBranch has been created by update-quarkus-all job, checkout it if (checkoutGitBranchIfExists(quarkusDowngradePrBranch, repoCredsId)) { - // apply patches from .ci/environments/quarkus-lts/patches - def patchesDirectory = '.ci/environments/quarkus-lts/patches' - def patches = findFiles(glob: "${patchesDirectory}/*") - - if (patches && patches.size() > 0) { - patches.each { patch -> - echo "Applying patch ${patch}" - sh "git apply --whitespace=fix ${patch}" - } - } else { - echo "No patches found at ${patchesDirectory}" - } + // thefollowing script takes care of applying all patches needed when downgrading to Quarkus LTS + // i.e., it will apply all patches found under .ci/environments/quarkus-lts/patches + sh '.ci/environments/update.sh quarkus-lts' pushIfChanged(quarkusDowngradePrBranch, repoCredsId, "Applied patches after Quarkus downgrade to ${getQuarkusVersion()}", "Quarkus LTS patches on ${quarkusDowngradePrBranch} have been applied") }