From 206b41ac1c888b39bd38dd26dc640cc464bd0ca2 Mon Sep 17 00:00:00 2001 From: radtriste Date: Tue, 29 Aug 2023 15:49:31 +0200 Subject: [PATCH] remove prod occurences --- .ci/jenkins/Jenkinsfile.prod.nightly | 269 ------- .ci/jenkins/config/branch.yaml | 32 - .ci/jenkins/config/main.yaml | 2 - .ci/jenkins/dsl/jobs.groovy | 2 +- .ci/nightly-build-config.yaml | 61 -- .ci/nightly-project-dependencies.yaml | 82 --- docs/jenkins.md | 2 - .../jenkinsfiles/Jenkinsfile.prod.prepare | 664 ------------------ .../jenkinsfiles/Jenkinsfile.release.prepare | 4 - dsl/seed/jenkinsfiles/Jenkinsfile.seed.main | 2 - dsl/seed/jobs/root_jobs.groovy | 60 -- .../org/kie/jenkins/jobdsl/Utils.groovy | 4 - .../kie/jenkins/jobdsl/JobScriptsSpec.groovy | 1 - 13 files changed, 1 insertion(+), 1184 deletions(-) delete mode 100644 .ci/jenkins/Jenkinsfile.prod.nightly delete mode 100644 .ci/nightly-build-config.yaml delete mode 100644 .ci/nightly-project-dependencies.yaml delete mode 100644 dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare diff --git a/.ci/jenkins/Jenkinsfile.prod.nightly b/.ci/jenkins/Jenkinsfile.prod.nightly deleted file mode 100644 index d7ac44cfe..000000000 --- a/.ci/jenkins/Jenkinsfile.prod.nightly +++ /dev/null @@ -1,269 +0,0 @@ -@Library('jenkins-pipeline-shared-libraries')_ - -import org.kie.jenkins.MavenCommand - -pipeline { - agent { - label 'ubuntu' - } - tools { - maven 'maven_3.8.6' - jdk 'jdk_11_latest' - nodejs 'nodejs-16.2.0' - } - parameters { - string(description: 'The UMB message version', name: 'UMB_VERSION', defaultValue: 'main') - string(description: 'The product version, if not provided the kogito-runtimes main branch one will be use', name: 'PRODUCT_VERSION') - string(description: 'The drools product version, if not provided the drools main branch one will be used', name: 'DROOLS_PRODUCT_VERSION') - string(description: 'The config repository branch', name: 'CONFIG_BRANCH', defaultValue: 'master') - } - options { - buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10') - } - environment { - DATE_TIME_SUFFIX_FORMAT = 'yyyyMMddHH' - } - stages { - stage('Initialize') { - steps { - script { - // Fetch versions from pom if not provided - env.PRODUCT_VERSION = "${PRODUCT_VERSION ?: parseVersionFromPom('kiegroup/kogito-runtimes', getBuildBranch())}" - env.DROOLS_PRODUCT_VERSION = "${DROOLS_PRODUCT_VERSION ?: parseVersionFromPom('kiegroup/drools', getDroolsBranch())}" - - // Needed by Kogito Apps - setupCypressEnv('9.7.0') - } - } - } - stage('Install build-chain tool') { - steps { - script { - println "[INFO] Installing build-chain tool" - sh "npm install -g @kie/build-chain-action${env.NPM_REGISTRY_URL ? " -registry=${NPM_REGISTRY_URL}" : ''}" - - sh "npm list -g | grep build-chain" - } - } - } - stage('Clone build configuration repo') { - steps { - script { - def currentBranch = getBuildConfigBranch() - println "Checking out ${env.BUILD_CONFIGURATION_REPO_URL}:${currentBranch} into build_config folder" - sh "git clone -b ${currentBranch} --single-branch ${env.BUILD_CONFIGURATION_REPO_URL} build_config" - - // export PME parameters and build scripts from nightly build config - def buildConfigAdditionalVariables = [ - 'productVersion': env.PRODUCT_VERSION, - 'droolsProductVersion': env.DROOLS_PRODUCT_VERSION - ] - pmebuild.parseBuildConfig("$WORKSPACE/build_config/openshift-serverless-logic/nightly", buildConfigAdditionalVariables) - - def PME_BUILD_VARIABLES = env.PME_BUILD_VARIABLES.split(';').collect{ it.split('=')}.inject([:]) {map, item -> map << [(item.length == 2 ? item[0] : null): (item.length == 2 ? item[1] : null)]} - - // export Quarkus community versions - env.QUARKUS_VERSION_COMMUNITY = PME_BUILD_VARIABLES['quarkusVersionCommunity'] - env.QUARKUS_VERSION = PME_BUILD_VARIABLES['quarkusVersion'].replaceAll("\\{\\{.*\\}\\}", env.QUARKUS_VERSION_COMMUNITY) - env.QUARKUS_PLATFORM_VERSION = PME_BUILD_VARIABLES['quarkusPlatformVersion'].replaceAll("\\{\\{.*\\}\\}", env.QUARKUS_VERSION_COMMUNITY) - - // export images registries - env.IMAGE_TAG_VERSION = PME_BUILD_VARIABLES['imageTagVersion'] - env.DATA_INDEX_IMAGE_REGISTRY = PME_BUILD_VARIABLES['dataIndexImageRegistry'].replaceAll("\\{\\{.*\\}\\}", env.IMAGE_TAG_VERSION) - env.SWF_BUILDER_IMAGE_REGISTRY = PME_BUILD_VARIABLES['swfBuilderImageRegistry'].replaceAll("\\{\\{.*\\}\\}", env.IMAGE_TAG_VERSION) - env.SWF_DEVMODE_IMAGE_REGISTRY = PME_BUILD_VARIABLES['swfDevModeImageRegistry'].replaceAll("\\{\\{.*\\}\\}", env.IMAGE_TAG_VERSION) - env.OPERATOR_IMAGE_REGISTRY = PME_BUILD_VARIABLES['operatorImageRegistry'].replaceAll("\\{\\{.*\\}\\}", env.IMAGE_TAG_VERSION) - - sh 'printenv' - } - } - } - stage('Build Nightly projects') { - steps { - script { - def pipelineHelper = new PipelineHelper(this) - pipelineHelper.retry( - { - withCredentials([string(credentialsId: "kie-ci1-token", variable: 'GITHUB_TOKEN')]) { - def SETTINGS_XML_ID = '5d9884a1-178a-4d67-a3ac-9735d2df2cef' - def buildBranch = getBuildBranch() - def definitionFile = "https://raw.githubusercontent.com/\\\${GROUP:kiegroup}/kogito-pipelines/${getDefinitionFileBranch()}/.ci/nightly-build-config.yaml" - - configFileProvider([configFile(fileId: "${SETTINGS_XML_ID}", variable: 'PME_MAVEN_SETTINGS_XML')]) { - sh "build-chain build branch --token=${GITHUB_TOKEN} -f ${definitionFile} -b ${buildBranch} -o bc -p kiegroup/kogito-runtimes --fullProjectDependencyTree --skipParallelCheckout" - } - } - }, 2, 480*60) - } - } - } - stage('Upload maven repository') { - steps { - script { - echo "[INFO] Start uploading ${env.WORKSPACE}/deployDirectory" - if(fileExists("${env.WORKSPACE}/deployDirectory")){ - def destDir = "${env.WORKSPACE}/deployDirectoryFinal/openshift-serverless-logic-${PRODUCT_VERSION}-maven-repository/maven-repository/" - sh "mkdir -p ${destDir}" - sh "mv ${env.WORKSPACE}/deployDirectory/* ${destDir}" - dir("${env.WORKSPACE}/deployDirectoryFinal") { - sh "zip -r maven-repository-${env.DATE_TIME_SUFFIX} ." - def relativeFile = "rhoss/rhoss-logic-${PRODUCT_VERSION}.nightly" - def folder="${env.RCM_GUEST_FOLDER}/${relativeFile}" - - util.withKerberos('rhba-prod-keytab') { - sh "ssh 'rhba-prod@${env.RCM_HOST}' 'mkdir -p ${folder}'" - sh "rsync -rlp --info=progress2 maven-repository-${env.DATE_TIME_SUFFIX}.zip rhba-prod@${env.RCM_HOST}:staging/${relativeFile}" - } - } - } - } - } - } - stage ('Extract Git Information') { - steps { - script { - def projectFolders = sh(returnStdout: true, script: "ls ${env.WORKSPACE}/bc").trim().split("\n") - for (f in projectFolders) { - dir("${env.WORKSPACE}/bc/${f}") { - def projectName = f.replace("_", "/") - // extract git infos - util.storeGitInformation(projectName) - env.ALREADY_BUILT_PROJECTS = "${env.ALREADY_BUILT_PROJECTS ?: ''}${projectName};" - - def sanitizedProjectName = f.replaceAll('/', '_').replaceAll('-', '_') - def buildScript = env["PME_BUILD_SCRIPT_${sanitizedProjectName}"] - def pomPath = maven.getProjectPomFromBuildCmd(buildScript) - env["VERSION_${f}"] = maven.mvnGetVersionProperty(new MavenCommand(this).withProperty('productized'), 'project.version', pomPath) - } - } - - sh 'printenv' - } - } - } - stage ('Send UMB Message to QE.') { - steps { - script { - echo '[INFO] Sending OPENSHIFT SERVERLESS LOGIC UMB message to QE.' - - def mavenRepositoryFileUrl = "${env.STAGING_SERVER_URL}/rhoss/rhoss-logic-${PRODUCT_VERSION}.nightly/maven-repository-${env.DATE_TIME_SUFFIX}.zip" - def topic = "VirtualTopic.qe.ci.ba.openshift-serverless-logic.${env.UMB_VERSION}.nightly.trigger" - def eventType = "openshift-serverless-logic-${env.UMB_VERSION}-nightly-qe-trigger" - def messageBody = getMessageBody( - mavenRepositoryFileUrl, - env.ALREADY_BUILT_PROJECTS, - ['serverlesslogic': env['VERSION_kiegroup_kogito-runtimes'], 'serverlesslogic-rhba': env['VERSION_kiegroup_kogito-runtimes'], 'drools': env.VERSION_kiegroup_drools, 'platform.quarkus.bom': env.QUARKUS_PLATFORM_VERSION, 'quarkus.bom': env.QUARKUS_VERSION], - ['data-index-ephemeral': env.DATA_INDEX_IMAGE_REGISTRY, 'swf-builder': env.SWF_BUILDER_IMAGE_REGISTRY, 'swf-devmode': env.SWF_DEVMODE_IMAGE_REGISTRY, 'operator': env.OPERATOR_IMAGE_REGISTRY], - gitHashesToCollection(env.GIT_INFORMATION_HASHES) - ) - echo "[INFO] Message Body: ${messageBody}" - echo "[INFO] Topic: ${topic}" - echo "[INFO] Event Type: ${eventType}" - build job: env.SEND_UMB_MESSAGE_JOB_PATH, parameters: [ - [$class: 'StringParameterValue', name: 'MESSAGE_BODY', value: messageBody], - [$class: 'StringParameterValue', name: 'TOPIC', value: topic], - [$class: 'StringParameterValue', name: 'EVENT_TYPE', value: eventType] - ] - echo '[SUCCESS] Message was successfully sent.' - } - } - } - } - post { - failure { - emailext body: 'OPENSHIFT SERVERLESS LOGIC ${PRODUCT_VERSION}:nightly-build #${BUILD_NUMBER} was: ' + "${currentBuild.currentResult}" + '\n' + - 'Please look here: ${BUILD_URL} \n' + - ' \n' + - '${BUILD_LOG, maxLines=750}', subject: 'OPENSHIFT SERVERLESS LOGIC ${PRODUCT_VERSION}:nightly-build #${BUILD_NUMBER}: ' + "${currentBuild.currentResult}", to: 'kie-jenkins-builds@redhat.com' - } - unstable { - emailext body: 'OPENSHIFT SERVERLESS LOGIC ${PRODUCT_VERSION}:nightly-build #${BUILD_NUMBER} was: ' + "${currentBuild.currentResult}" + '\n' + - 'Please look here: ${BUILD_URL} \n' + - ' \n' + - 'Failed tests: ${BUILD_URL}/testReport \n' + - ' \n' + - '${BUILD_LOG, maxLines=750}', subject: 'OPENSHIFT SERVERLESS LOGIC ${PRODUCT_VERSION}:nightly-build #${BUILD_NUMBER}: ' + "${currentBuild.currentResult}", to: 'kie-jenkins-builds@redhat.com' - } - fixed { - emailext body: 'OPENSHIFT SERVERLESS LOGIC ${PRODUCT_VERSION}:nightly-build #${BUILD_NUMBER} was: ' + "${currentBuild.currentResult}" + '\n' + - 'Please look here: ${BUILD_URL}', subject: 'OPENSHIFT SERVERLESS LOGIC ${PRODUCT_VERSION}:nightly-build #${BUILD_NUMBER}: ' + "${currentBuild.currentResult}", to: 'kie-jenkins-builds@redhat.com' - } - always { - archiveArtifacts artifacts: '**/*.maven.log', fingerprint: false, defaultExcludes: true, caseSensitive: true, allowEmptyArchive: true - - echo 'Generating JUnit report...' - junit allowEmptyResults: true, healthScaleFactor: 1.0, testResults: '**/target/*-reports/TEST-*.xml' - - echo 'Archiving logs...' - archiveArtifacts excludes: '**/target/checkstyle.log', artifacts: '**/*.maven.log,**/target/*.log', fingerprint: false, defaultExcludes: true, caseSensitive: true, allowEmptyArchive: true - } - cleanup { - cleanWs() - } - } -} - -def getMessageBody(String mavenRepositoryFileUrl, String alreadyBuiltProjects, Map versions, Map imagesRegistries, Map scmHashes) { - def alreadyBuiltProjectsArray = (alreadyBuiltProjects ?: '').split(";") - return """ -{ - "maven_repository_file_url": "${mavenRepositoryFileUrl}", - "version": ${new groovy.json.JsonBuilder(versions).toString()}, - "image": ${new groovy.json.JsonBuilder(imagesRegistries).toString()}, - "scm_hash": ${new groovy.json.JsonBuilder(scmHashes).toString()}, - "built_projects": ${new groovy.json.JsonBuilder(alreadyBuiltProjectsArray).toString()} -}""" -} - -def setupCypressEnv(String cypressVersion) { - if (env.CYPRESS_BINARY_URL) { - env.CYPRESS_INSTALL_BINARY = "${CYPRESS_BINARY_URL}/cypress-${cypressVersion}.zip" - } -} - -def gitHashesToCollection(String gitInformationHashes) { - return gitInformationHashes.replaceAll(/([\w\d\-\_\.]*\/)([\w\d\-\_\.]*)/,'$2').split(';').findAll { it.split('=').size() }.collectEntries{ [it.split('=')[0], it.split('=')[1]] } -} - -String getBuildConfigBranch() { - return env.CONFIG_BRANCH ?: env.DEFAULT_CONFIG_BRANCH ?: env.BRANCH_NAME ?: env.GIT_BRANCH -} - -String getBuildBranch() { - // Fallback to main if none exist - return env.CHANGE_BRANCH ?: env.BRANCH_NAME ?: env.GIT_BRANCH ?: 'main' -} - -String getDroolsBranch() { - return calculateKieRepoBranch(getBuildBranch()) -} - -String getDefinitionFileBranch() { - // Fallback to getBuildBranch if DEFINITION_FILE_BRANCH not set - return env.DEFINITION_FILE_BRANCH ?: getBuildBranch() -} - -String calculateKieRepoBranch(String branch) { - /* The Drools/OptaPlanner major version is shifted by 7 from the Kogito major version: - Kogito 1.x.y -> Drools 8.x.y. - Kogito 1.x.y -> OptaPlanner 8.x.y. */ - int majorVersionShift = 7 - String [] branchSplit = branch.split("\\.") - if (branchSplit.length == 3) { - Integer optaplannerMajorVersion = Integer.parseInt(branchSplit[0]) + majorVersionShift - return "${optaplannerMajorVersion}.${branchSplit[1]}.${branchSplit[2]}" - } else { - return branch - } -} - -// Parse version from main branch of the given project -// * project: in the form of owner/repository -def parseVersionFromPom(String project, String branch) { - def pomFilename = "${project.replaceAll("/", "_")}_pom.xml" - def pomPath = "${env.WORKSPACE}/${pomFilename}" - - sh "curl https://raw.githubusercontent.com/${project}/${branch}/pom.xml -o ${pomPath}" - def pom = readMavenPom file: pomPath - return pom.getVersion().replaceAll('-SNAPSHOT', '') -} diff --git a/.ci/jenkins/config/branch.yaml b/.ci/jenkins/config/branch.yaml index c7591c866..3c00a6f59 100644 --- a/.ci/jenkins/config/branch.yaml +++ b/.ci/jenkins/config/branch.yaml @@ -23,18 +23,6 @@ environments: # ADDITIONAL_TIMEOUT: 720 # ids: # - native - # native-lts: - # env_vars: - # NATIVE: true - # BUILD_MVN_OPTS: -Dproductized -Ddata-index-ephemeral.image=quay.io/kiegroup/kogito-data-index-ephemeral - # BUILD_MVN_OPTS_CURRENT: -Dnative -Dquarkus.native.container-build=true - # QUARKUS_BRANCH: '2.13' - # ADDITIONAL_TIMEOUT: 720 - # BUILD_ENVIRONMENT: quarkus-lts - # ids: - # - native - # - prod - # - lts # quarkus-main: # enabled: false # env_vars: @@ -55,15 +43,6 @@ environments: # ids: # - quarkus # - quarkus3 - # quarkus-lts: - # pull_request_default_check: false - # env_vars: - # BUILD_MVN_OPTS: -Dproductized -Ddata-index-ephemeral.image=quay.io/kiegroup/kogito-data-index-ephemeral - # QUARKUS_BRANCH: '2.13' - # ids: - # - quarkus - # - lts - # - prod sonarcloud: auto_generation: false env_vars: @@ -75,7 +54,6 @@ environments: auto_generation: false ids: - ecosystem -productized_branch: true disable: triggers: false repositories: @@ -89,16 +67,6 @@ repositories: # - name: kie-tools # - name: kogito-docs # - name: kie-docs -# branch: main-kogito -productized_repositories: -- name: kogito-pipelines -- name: kogito-runtimes -- name: kogito-apps -- name: kogito-examples -- name: kogito-images -- name: kogito-serverless-operator -- name: kogito-operator -- name: kogito-docs git: author: name: kiegroup diff --git a/.ci/jenkins/config/main.yaml b/.ci/jenkins/config/main.yaml index ca3320e4e..531d6eecc 100644 --- a/.ci/jenkins/config/main.yaml +++ b/.ci/jenkins/config/main.yaml @@ -9,12 +9,10 @@ ecosystem: - kogito.* - name: kie-tools ignore_release: true - ignore_productization: true regexs: - kie-tools.* - name: kie-docs ignore_release: true - ignore_productization: true regexs: - kie-docs.* git: diff --git a/.ci/jenkins/dsl/jobs.groovy b/.ci/jenkins/dsl/jobs.groovy index e62ceb8f6..d115ab7a1 100644 --- a/.ci/jenkins/dsl/jobs.groovy +++ b/.ci/jenkins/dsl/jobs.groovy @@ -263,7 +263,7 @@ void setupReleaseCloudJob() { GIT_BRANCH_NAME: "${GIT_BRANCH}", GIT_AUTHOR: "${GIT_AUTHOR_NAME}", - IMAGE_REGISTRY_CREDENTIALS: "${CLOUD_IMAGE_REGISTRY_CREDENTIALS_RELEASE}", + IMAGE_REGISTRY_CREDENTIALS: "${CLOUD_IMAGE_REGISTRY_CREDENTIALS}", IMAGE_REGISTRY: "${CLOUD_IMAGE_REGISTRY}", IMAGE_NAMESPACE: "${CLOUD_IMAGE_NAMESPACE}", BRANCH_FOR_LATEST: "${CLOUD_IMAGE_LATEST_GIT_BRANCH}", diff --git a/.ci/nightly-build-config.yaml b/.ci/nightly-build-config.yaml deleted file mode 100644 index 9613fbb85..000000000 --- a/.ci/nightly-build-config.yaml +++ /dev/null @@ -1,61 +0,0 @@ -version: "2.1" - -dependencies: ./nightly-project-dependencies.yaml - -pre: | - export PME_CMD="java -jar ${{ env.PME_CLI_PATH }} -s ${{ env.PME_MAVEN_SETTINGS_XML }} -DallowConfigFilePrecedence=true -DprojectSrcSkip=false" - echo "PME_CMD=${{ env.PME_CMD }}" - export BUILD_MVN_OPTS="${{ env.BUILD_MVN_OPTS }} -s ${{ env.PME_MAVEN_SETTINGS_XML }}" - echo "BUILD_MVN_OPTS=${{ env.BUILD_MVN_OPTS }}" - export ALIGN_QUARKUS="mvn versions:compare-dependencies -DremotePom=io.quarkus:quarkus-bom:${{ env.QUARKUS_VERSION_COMMUNITY }} -DupdatePropertyVersions=true -DupdateDependencies=true -DgenerateBackupPoms=false -Dproductized -s ${{ env.PME_MAVEN_SETTINGS_XML }}" - echo "ALIGN_QUARKUS=${{ env.ALIGN_QUARKUS }}" - -default: - build-command: - current: mvn clean install -Dproductized=true -DskipTests=true ${{ env.BUILD_MVN_OPTS }} - upstream: mvn clean install -Dquickly -Dproductized=true -DskipTests=true ${{ env.BUILD_MVN_OPTS }} - downstream: mvn clean install -Dquickly -Dproductized=true -DskipTests=true ${{ env.BUILD_MVN_OPTS }} - after: - current: | - docker system prune -f - -build: - - project: kiegroup/drools - build-command: - upstream: | - ${{ env.PME_CMD }} ${{ env.PME_ALIGNMENT_PARAMS_kiegroup_drools }} - bash -c "set -o pipefail ; ${{ env.ALIGN_QUARKUS }} -pl :drools-build-parent | tee ${{ env.WORKSPACE }}/drools.quarkus-alignment.maven.log" - bash -c "set -o pipefail ; ${{ env.PME_BUILD_SCRIPT_kiegroup_drools }} ${{ env.BUILD_MVN_OPTS }} | tee ${{ env.WORKSPACE }}/drools.maven.log" - - - project: kiegroup/kogito-runtimes - build-command: - current: | - ${{ env.PME_CMD }} ${{ env.PME_ALIGNMENT_PARAMS_kiegroup_kogito_runtimes }} - bash -c "set -o pipefail ; ${{ env.ALIGN_QUARKUS }} -pl :kogito-dependencies-bom | tee ${{ env.WORKSPACE }}/kogito_runtimes.quarkus-alignment.maven.log" - bash -c "set -o pipefail ; ${{ env.PME_BUILD_SCRIPT_kiegroup_kogito_runtimes }} ${{ env.BUILD_MVN_OPTS }} | tee ${{ env.WORKSPACE }}/kogito_runtimes.maven.log" - - - project: kiegroup/kogito-apps - build-command: - downstream: | - ${{ env.PME_CMD }} ${{ env.PME_ALIGNMENT_PARAMS_kiegroup_kogito_apps }} - bash -c "set -o pipefail ; ${{ env.ALIGN_QUARKUS }} -pl :kogito-apps-build-parent | tee ${{ env.WORKSPACE }}/kogito_apps.quarkus-alignment.maven.log" - bash -c "set -o pipefail ; ${{ env.PME_BUILD_SCRIPT_kiegroup_kogito_apps }} ${{ env.BUILD_MVN_OPTS }} | tee ${{ env.WORKSPACE }}/kogito_apps.maven.log" - - - project: kiegroup/kogito-examples - build-command: - downstream: | - ${{ env.PME_CMD }} ${{ env.PME_ALIGNMENT_PARAMS_kiegroup_kogito_examples }} - bash -c "set -o pipefail ; ${{ env.ALIGN_QUARKUS }} | tee ${{ env.WORKSPACE }}/kogito_examples.quarkus-alignment.maven.log" - bash -c "set -o pipefail ; ${{ env.PME_BUILD_SCRIPT_kiegroup_kogito_examples }} ${{ env.BUILD_MVN_OPTS }} | tee ${{ env.WORKSPACE }}/kogito_examples.maven.log" - - - project: kiegroup/kogito-images - build-command: - downstream: | - export MAVEN_OPTIONS="-s ${{ env.PME_MAVEN_SETTINGS_XML }}" - echo "MAVEN_OPTIONS=${{ env.MAVEN_OPTIONS }}" - export NIGHTLY="true" - echo "NIGHTLY=${{ env.NIGHTLY }}" - export NIGHTLY_DEPLOY_FOLDER="${{ env.WORKSPACE }}/deployDirectory" - echo "NIGHTLY_DEPLOY_FOLDER=${{ env.NIGHTLY_DEPLOY_FOLDER }}" - ${{ env.PME_CMD }} ${{ env.PME_ALIGNMENT_PARAMS_kiegroup_kogito_images }} - bash -c "set -o pipefail ; ${{ env.PME_BUILD_SCRIPT_kiegroup_kogito_images }} ${{ env.BUILD_MVN_OPTS }} | tee ${{ env.WORKSPACE }}/kogito_images.maven.log" \ No newline at end of file diff --git a/.ci/nightly-project-dependencies.yaml b/.ci/nightly-project-dependencies.yaml deleted file mode 100644 index 93da3ce4d..000000000 --- a/.ci/nightly-project-dependencies.yaml +++ /dev/null @@ -1,82 +0,0 @@ -version: "2.1" - -dependencies: - - project: kiegroup/drools - mapping: - dependencies: - default: - - source: (\d*)\.(.*)\.(.*) - targetExpression: "process.env.GITHUB_BASE_REF.replace(/(\\d*)\\.(.*)\\.(.*)/g, (m, n1, n2, n3) => `${+n1-7}.${n2}.${n3}`)" - dependant: - default: - - source: (\d*)\.(.*)\.(.*) - targetExpression: "process.env.GITHUB_BASE_REF.replace(/(\\d*)\\.(.*)\\.(.*)/g, (m, n1, n2, n3) => `${+n1+7}.${n2}.${n3}`)" - - - project: kiegroup/kogito-runtimes - dependencies: - - project: kiegroup/drools - mapping: - dependencies: - default: - - source: (\d*)\.(.*)\.(.*) - targetExpression: "process.env.GITHUB_BASE_REF.replace(/(\\d*)\\.(.*)\\.(.*)/g, (m, n1, n2, n3) => `${+n1+7}.${n2}.${n3}`)" - dependant: - default: - - source: (\d*)\.(.*)\.(.*) - targetExpression: "process.env.GITHUB_BASE_REF.replace(/(\\d*)\\.(.*)\\.(.*)/g, (m, n1, n2, n3) => `${+n1-7}.${n2}.${n3}`)" - exclude: - - kiegroup/kogito-examples - - kiegroup/kogito-apps - - kiegroup/kogito-images - - - project: kiegroup/kogito-apps - dependencies: - - project: kiegroup/kogito-runtimes - mapping: - dependencies: - default: - - source: (\d*)\.(.*)\.(.*) - targetExpression: "process.env.GITHUB_BASE_REF.replace(/(\\d*)\\.(.*)\\.(.*)/g, (m, n1, n2, n3) => `${+n1+7}.${n2}.${n3}`)" - dependant: - default: - - source: (\d*)\.(.*)\.(.*) - targetExpression: "process.env.GITHUB_BASE_REF.replace(/(\\d*)\\.(.*)\\.(.*)/g, (m, n1, n2, n3) => `${+n1-7}.${n2}.${n3}`)" - exclude: - - kiegroup/kogito-examples - - kiegroup/kogito-runtimes - - kiegroup/kogito-images - - - project: kiegroup/kogito-examples - dependencies: - - project: kiegroup/kogito-runtimes - - project: kiegroup/kogito-apps - mapping: - dependencies: - default: - - source: (\d*)\.(.*)\.(.*) - targetExpression: "process.env.GITHUB_BASE_REF.replace(/(\\d*)\\.(.*)\\.(.*)/g, (m, n1, n2, n3) => `${+n1+7}.${n2}.${n3}`)" - dependant: - default: - - source: (\d*)\.(.*)\.(.*) - targetExpression: "process.env.GITHUB_BASE_REF.replace(/(\\d*)\\.(.*)\\.(.*)/g, (m, n1, n2, n3) => `${+n1-7}.${n2}.${n3}`)" - exclude: - - kiegroup/kogito-apps - - kiegroup/kogito-runtimes - - kiegroup/kogito-images - - - project: kiegroup/kogito-images - dependencies: - - project: kiegroup/kogito-examples - mapping: - dependencies: - default: - - source: (\d*)\.(.*)\.(.*) - targetExpression: "process.env.GITHUB_BASE_REF.replace(/(\\d*)\\.(.*)\\.(.*)/g, (m, n1, n2, n3) => `${+n1+7}.${n2}.${n3}`)" - dependant: - default: - - source: (\d*)\.(.*)\.(.*) - targetExpression: "process.env.GITHUB_BASE_REF.replace(/(\\d*)\\.(.*)\\.(.*)/g, (m, n1, n2, n3) => `${+n1-7}.${n2}.${n3}`)" - exclude: - - kiegroup/kogito-runtimes - - kiegroup/kogito-apps - - kiegroup/kogito-examples \ No newline at end of file diff --git a/docs/jenkins.md b/docs/jenkins.md index 33bab7278..4d3033257 100644 --- a/docs/jenkins.md +++ b/docs/jenkins.md @@ -142,8 +142,6 @@ environments: ids: - List of ids identifying the environment -productized_branch: true - # Used to force the disabling of triggers # Useful when a branch is no more maintained but you still want to keep job history disable: diff --git a/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare b/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare deleted file mode 100644 index dad5b6f9f..000000000 --- a/dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare +++ /dev/null @@ -1,664 +0,0 @@ -import org.jenkinsci.plugins.workflow.libs.Library -import java.util.regex.Pattern - -@Library('jenkins-pipeline-shared-libraries')_ - -// parameters -// 1. _RELEASE_BRANCH -// 2. _UPDATE_VERSION (this includes also dependencies) -// 3. QUARKUS_VERSION -// 4. DOWNGRADE_QUARKUS_PR_BRANCH -// 5. ADDITIONAL_BUILD_MAVEN_OPTS -// 6. PROJECTS_TO_REMOVE_FROM_PR_CHECKS - -seedConfig = [:] -mainBranchConfig = [:] -repositoriesToBranch = [] - -pipeline{ - agent{ - label 'rhel8 && !built-in' - } - stages{ - stage('Initialize'){ - steps{ - script { - checkout scm - - String projectListStr = getEcosystemProjects().collect { "${getRepoNameCamelCase(it.name)} ${getBranchFromRepository(it.name)}" }.join(' / ') - currentBuild.displayName = "Productize Branch for ${projectListStr}" - } - } - } - - stage('Create productized branches'){ - steps{ - script { - List repositories = getProdRepositoriesToBranch() - createBranches(repositories) - } - } - } - - // update the main seed config by adding the new prod branch, e.g., - // - name: 8.36.x-prod - // seed: - // branch: seed-drools-8.36.x // this branch MUST already exist - stage('Update main seed config') { - steps { - script { - String seedConfigFile = env.SEED_CONFIG_FILE_PATH - - dir(checkoutMainSeedConfigFileRepo()) { - def seedConfig = readYaml file: seedConfigFile - - if (!seedConfig.git.branches.find { it.name == getEcosystemProductizedBranch() }) { - def branchConfig = [ - name: getEcosystemProductizedBranch(), - seed: [ - branch: getSeedRepoReleaseBranch(), - ] - ] - - seedConfig.git.branches.add(branchConfig) - } - - echo "Write seed config => ${seedConfig}" - sh "rm ${seedConfigFile}" - writeYaml file: seedConfigFile, data: seedConfig, overwrite: true - - pushIfChanged(env.SEED_CONFIG_FILE_GIT_BRANCH, env.SEED_CONFIG_FILE_GIT_AUTHOR_CREDS_ID, "Add productized branch ${getEcosystemProductizedBranch()} after upstream release", "Main config has been updated with release branch ${getEcosystemProductizedBranch()}") - } - } - } - } - - // 1. update seed config repo on productized branch (e.g., 1.37.x-prod) - // - enable productized profile (-Dproductized) on jenkins environments branch.yaml [this MUST be executed only on config file repo, e.g., kogito-pipelines] - // - disable some environments when branching as they make no sense by default [this MUST be executed only on config file repo, e.g., kogito-pipelines] - // - set productized_repositories[].branch to the productized one, e.g., 1.37.x-prod - // - set productized_repositories[].is_branch_config_repo to true for the config file repo - // - enable productized profile (-Dproductized) on build chain config - // - do these changes directly on the prod branch - - - stage("Update branch config on productized branch"){ - steps{ - script { - def prodBranch = getBranchConfigProductizedBranch() - def prodRepositories = getProdRepositoriesToBranch() - - dir(checkoutMainBranchSeedConfigFileRepo()) { - getOrCreateGitBranch(prodBranch, getMainBranchConfigFileGitAuthorCredentialsId()) - - def branchConfigFilePath = getProdBranchConfigFilePath() - def branchConfig = readYaml file: branchConfigFilePath - - branchConfig.productized_repositories = prodRepositories - branchConfig.productized_branch = true - - // keep only those environments that are really needed on productized branch: - // native, quarkus-branch and default if exists - def envsToKeep = ['native', 'quarkus-branch', 'default'] - enabledEnvs = branchConfig.environments.findAll { envName, envData -> envsToKeep.contains(envName) } - - // additional maven opt that enables productized profile - // FIXME do we need -Dproductized here as we are already adding it on buildchain config - def buildMvnOpts = "-Dproductized ${getAdditionalDefaultBuildMavenOpts()} " - - // create default env if not already existing - enabledEnvs.default = enabledEnvs.default ?: [:] - - // apply changes on remaining envs - enabledEnvs.each { envName, envData -> - // ensure env is enabled - envData.enabled = true - - envData.env_vars = envData.env_vars ?: [:] - envData.env_vars.BUILD_MVN_OPTS = buildMvnOpts + (envData.env_vars.BUILD_MVN_OPTS ?: '') - } - - // update environments - branchConfig.environments = enabledEnvs - - // ignore the job creation for jobs in environment which are not defined (apart from the default env) - branchConfig.generation_config = branchConfig.generation_config ?: [:] - branchConfig.generation_config.missing_environment = 'ignore' - - // disable community triggers - branchConfig.disable = branchConfig.disable ?: [:] - branchConfig.disable.triggers = true - - // update repositories branches to the productized one - branchConfig.repositories.each { repo -> - repo.branch = getEcosystemProductizedBranch() - } - - // add cloud.images if operating on kogito project - - branchConfig.cloud = branchConfig.cloud ?: [:] - if (getEcosystemMainProject() == 'kogito') { - branchConfig.cloud.images = 'kogito-data-index-ephemeral,kogito-swf-builder,kogito-swf-devmode' - } - - // override nexus artifacts repository - - def nexusRepo = "${env.BXMS_QE_NEXUS}/content/repositories/osl-prod-nightly/" - branchConfig.maven = branchConfig.maven ?: [:] - branchConfig.maven.artifacts_repository = nexusRepo - - branchConfig.maven.artifacts_upload_repository = branchConfig.maven.artifacts_upload_repository ?: [:] - branchConfig.maven.artifacts_upload_repository.url = nexusRepo - branchConfig.maven.artifacts_upload_repository.creds_id = 'unpacks-zip-on-qa-nexus' - - echo "Write dsl branch_config => ${branchConfig}" - sh "rm -f ${branchConfigFilePath}" - writeYaml file: "${branchConfigFilePath}", data: branchConfig, overwrite: true - - // update build-chain configuration - - def buildChainConfigFilePath = readMainBranchConfig().buildchain_config.git.file_path - def buildChainConfig = readYaml file: buildChainConfigFilePath - - // add -Dproductized in BUILD_MVN_OPTS, then we don't have to add -Dproductized inside DSL configs - - sh "sed -i 's/export BUILD_MVN_OPTS=\"\\\${{ env.BUILD_MVN_OPTS }}/export BUILD_MVN_OPTS=\"\\\${{ env.BUILD_MVN_OPTS }} -Dproductized/' ${buildChainConfigFilePath}" - - // comment out projects we are not interested in from the buildchain-config.yaml - def projectToRemoveFromBCPRChecks = getProjectsToRemoveFromBuildChainConfig() - - if (projectToRemoveFromBCPRChecks.isEmpty()) { - echo "Removing projects ${projectToRemoveFromBCPRChecks} from build chain configuration" - - 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") - } - } - } - } - - - // 2. update productized branch on other projects - // - disable PR checks from jobs.groovy - // - comment out projects we are not interested in from the buildchain-config.yaml - // - disable GHA jobs no more needed by commenting out 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 - - String jobsGroovyPath = getJobDefinitionFilePath() - - 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, repoCredsId) - - 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}'" - } - - - // TODO iterate over PR workflows - // - comment out/remove if not needed (get these from param?) - - // push changes - pushIfChanged(repoConfig.branch, repoCredsId, "Pull request checks updated for productized branch", "Pull request checks updated for productized branch") - } - } - } - } - } - - // 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" - - def prodBranch = getEcosystemProductizedBranch() - String jobName = "${prodBranch}/setup-branch/0-setup-branch" - List jobParams = [] - jobParams.add(booleanParam(name: 'DEPLOY', 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)) - } - - if (!isDryRun()) { - def job = [:] - try { - // Retry 20 times every 5 min in order to assure seed job ran - retry(20) { - sleep 300 - echo "Build ./${jobName} with parameters ${jobParams}" - job = build(job: "./${jobName}", parameters: jobParams, wait: true, propagate: false) - } - - if (job.result != 'SUCCESS') { - unstable("Update projects version on repositories was not successful") - } - } catch (err) { - unstable("Error executing the ${prodBranch} setup job ...") - String msg = "ERROR: Setup branch job on newly created release branch '${prodBranch}' was unsuccessful." - if(job) { - msg += "\nPlease review job ${job.absoluteUrl}..." - } - sendNotification(msg) - } - } else { - // dry run - just print the job name and params - echo "Build ./${jobName} with parameters ${jobParams}" - } - } - } - } - - // 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 - - 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 = [:] - try { - // Retry 20 times every 5 min in order to assure seed job ran - retry(20) { - sleep 300 - echo "Build ./${jobName} with parameters ${jobParams}" - job = build(job: "./${jobName}", parameters: jobParams, wait: true, propagate: false) - } - - if (job.result != 'SUCCESS') { - unstable("Downgrade quarkus version on repositories was not successful") - } else { - 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' - - 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)) { - // 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 - def updateQuarkusLtsScriptPath = '.ci/environments/update.sh' - if (fileExists(updateQuarkusLtsScriptPath)) { - sh "${updateQuarkusLtsScriptPath} quarkus-lts" - } else { - echo "[WARN] Unable to find '${updateQuarkusLtsScriptPath}' for '${repository}'" - } - - pushIfChanged(quarkusDowngradePrBranch, repoCredsId, "Applied patches after Quarkus downgrade to ${getQuarkusVersion()}", "Quarkus LTS patches on ${quarkusDowngradePrBranch} have been applied") - } - } - } - } - } catch (err) { - unstable("Error executing update quarkus all...") - String msg = "ERROR: Update quarkus all job on newly created prod branch was unsuccessful." - if(job) { - msg += "\nPlease review job ${job.absoluteUrl}..." - } - sendNotification(msg) - } - } - } - } - } - } - post{ - unsuccessful { - script { - sendNotification("${getEcosystemMainProject()}: Branch Productization Pipeline job #${BUILD_NUMBER} was: ${currentBuild.currentResult}\nPlease look here: ${BUILD_URL}") - } - } - success { - script { - sendNotification("${getEcosystemMainProject()}: Branch Productization Pipeline job #${BUILD_NUMBER} was: ${currentBuild.currentResult}") - } - } - } -} - - -void sendNotification(String body) { - echo 'Send Notification' - echo body - if (!isDryRun()) { - emailext body: body, subject: "[${getEcosystemProductizedBranch()}] ${getEcosystemMainProject()}", - to: env.CI_EMAIL_TO - } -} - -// Retrieve job parameters keys or values - -String getBranchParameterKey(String projectName) { - return "${projectName}_RELEASE_BRANCH".toUpperCase() -} - -String getProdBranchSuffixParameterKey(String projectName) { - def key = "${projectName}_PROD_BRANCH_SUFFIX".toUpperCase() - return params."${key}" -} - -def getProjectUpdateVersionKeys() { - return params.findAll{ it.key.contains('_UPDATE_VERSION') } -} - -String getQuarkusVersion() { - return params.QUARKUS_VERSION -} - -String getQuarkusDowngradePrBranch() { - return params.DOWNGRADE_QUARKUS_PR_BRANCH ?: "${getEcosystemProductizedBranch()}-${getQuarkusVersion()}-downgrade" -} - -Boolean isDryRun() { - return params.DRY_RUN -} - - -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() { - assert env.SEED_CONFIG_FILE_GIT_REPOSITORY : 'Missing main seed config file Git Repository into the environment. Please check the job configuration.' - assert env.SEED_CONFIG_FILE_GIT_AUTHOR_NAME : 'Missing main seed config file Git Author Name into the environment. Please check the job configuration.' - assert env.SEED_CONFIG_FILE_GIT_AUTHOR_CREDS_ID : 'Missing main seed config file Git Author Credentials ID into the environment. Please check the job configuration.' - assert env.SEED_CONFIG_FILE_GIT_BRANCH : 'Missing main seed config file Git Branch into the environment. Please check the job configuration.' - - String dirName = "seed-main-${env.SEED_CONFIG_FILE_GIT_REPOSITORY}" - dir(dirName) { - deleteDir() - checkout(githubscm.resolveRepository(env.SEED_CONFIG_FILE_GIT_REPOSITORY, env.SEED_CONFIG_FILE_GIT_AUTHOR_NAME, env.SEED_CONFIG_FILE_GIT_BRANCH, false, env.SEED_CONFIG_FILE_GIT_AUTHOR_CREDS_ID)) - sh "git checkout ${env.SEED_CONFIG_FILE_GIT_BRANCH}" - } - return dirName -} - -def readSeedConfig() { - assert env.SEED_CONFIG_FILE_PATH : 'Missing main seed config file Path into the environment. Please check the job configuration.' - if (!seedConfig) { - dir(checkoutMainSeedConfigFileRepo()) { - seedConfig = readYaml(file: "${env.SEED_CONFIG_FILE_PATH}") - } - } - return seedConfig -} - -String getProdBranchConfigFilePath() { - return readSeedConfig().seed.config_file.path -} - -String getMainBranchConfigFileGitAuthorCredentialsId() { - return readSeedConfig().seed.config_file.git.author.credentials_id -} - -String checkoutMainBranchSeedConfigFileRepo() { - String dirName = "seed-branch-${getMainBranchConfigFileGitRepository()}" - dir(dirName) { - deleteDir() - checkout(githubscm.resolveRepository(getMainBranchConfigFileGitRepository(), getMainBranchConfigFileGitAuthorName(), getMainBranchConfigFileGitBranch(), false, getMainBranchConfigFileGitAuthorCredentialsId())) - sh "git checkout ${getMainBranchConfigFileGitBranch()}" - } - return dirName -} - -def readMainBranchConfig() { - if (!mainBranchConfig) { - dir(checkoutMainBranchSeedConfigFileRepo()) { - mainBranchConfig = readYaml(file: "${getProdBranchConfigFilePath()}") - } - } - return mainBranchConfig -} - -String getRepoNameCamelCase(String repo) { - List words = repo.split('-') as List - 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 - -List getEcosystemProjects() { - return readSeedConfig().ecosystem.projects.findAll { ! (it.ignore_productization ? it.ignore_productization.toBoolean() : false) } -} - - -// Retrieve branch to productize starting from current repository/project - -String getProjectFromRepository(String repository) { - return getEcosystemProjects().find { project -> project.regexs?.any { Pattern.compile(it).matcher(repository).matches() } }?.name -} - -String getBranchFromProject(String projectName) { - String key = getBranchParameterKey(projectName) - assert params."${key}" : "No parameter ${key} available for project ${projectName}. Please check job configuration." - return params."${key}" -} - -String getBranchFromRepository(String repository) { - def projectName = getProjectFromRepository(repository) - if (projectName) { - return getBranchFromProject(projectName) - } else { - error "Cannot retrieve repository from repository name: ${repository}. Make sure it matches pattern from ecosystem projects in the main config" - } -} - -// Retrieve repositories to branch - -String getMainBranchConfigFileGitRepository() { - return readSeedConfig().seed.config_file.git.repository -} - -String getMainBranchConfigFileGitAuthorName() { - return readSeedConfig().seed.config_file.git.author.name -} - -String getMainBranchConfigFileGitBranch() { - return readSeedConfig().seed.config_file.git.branch -} - -List getProdRepositoriesToBranch() { - if (!repositoriesToBranch) { - repositoriesToBranch = readMainBranchConfig().productized_repositories.findAll { getProjectFromRepository(it.name) } - def branches = readSeedConfig().git.branches - if (!branches) { - error "No branches are defined in main configuration..." - } - - def releaseBranch = branches.find { it.name == getEcosystemReleaseBranch() }?.name ?: '' - if (!releaseBranch) { - error "No ${getEcosystemReleaseBranch()} branch defined into the main configuration..." - } - repositoriesToBranch.each { repoConfig -> - // set repoConfig.branch to the prod release one (e.g., 1.37.x) - input parameter - def baseBranch = getBranchFromRepository(repoConfig.name) - repoConfig.branch = repoConfig.branch ?: baseBranch ?: releaseBranch - - if (repoConfig.name == getMainBranchConfigFileGitRepository()) { - String gitAuthor = repoConfig.author?.name ?: readMainBranchConfig().git.author.name - if (gitAuthor == getMainBranchConfigFileGitAuthorName() && - repoConfig.branch == getEcosystemReleaseBranch()) { - // we are already going to branch it with the setup of the branch config - echo "Repository ${repoConfig.name} is branch config repository" - repoConfig.is_branch_config_repo = true - } - } - } - } - return repositoriesToBranch -} - -// Create productized branches - -String getProductizedBranchFromProject(String projectName) { - String suffix = getProdBranchSuffixParameterKey(projectName) ?: 'prod' - return "${getBranchFromProject(projectName)}-${suffix}" -} - -String getProductizedBranchFromRepository(String repository) { - def projectName = getProjectFromRepository(repository) - return getProductizedBranchFromProject(projectName) -} - -void createBranches(List repositories) { - repositories.each { repoConfig -> - String repoName = repoConfig.name - String baseBranch = repoConfig.branch - String prodBranch = getProductizedBranchFromRepository(repoConfig.name) - String gitAuthorCredsId = repoConfig.author?.credentials_id ?: readMainBranchConfig().git.author.credentials_id - assert gitAuthorCredsId : "Cannot find any credentials Id for git author ${repoConfig.author.name}. Please check your branch seed config file." - String gitAuthor = repoConfig.author?.name ?: readMainBranchConfig().git.author.name - - echo "Checkout repo ${gitAuthor}/${repoName} on branch ${baseBranch}" - dir(repoName) { - deleteDir() - checkout(githubscm.resolveRepository(repoName, gitAuthor, baseBranch, false, gitAuthorCredsId)) - getOrCreateGitBranch(prodBranch, gitAuthorCredsId) - } - // Update the branch with the new productized branch - repoConfig.branch = prodBranch - } -} - -// Update main seed config - -String getEcosystemMainProject() { - return readSeedConfig().ecosystem.main_project -} - -String getEcosystemProductizedBranch() { - return getProductizedBranchFromProject(getEcosystemMainProject()) -} - -String getEcosystemReleaseBranch() { - return getBranchFromProject(getEcosystemMainProject()) -} - -String getSeedRepoReleaseBranch() { - return readSeedConfig().git.branches.find{ it -> it.name == getEcosystemReleaseBranch() }?.seed.branch ?: "seed-${getEcosystemMainProject()}-${getEcosystemReleaseBranch()}" -} - -String getBranchConfigProductizedBranch() { - // Check if repository already branched - return (getProdRepositoriesToBranch().find { it -> it.is_branch_config_repo }?.branch) ?: "${getEcosystemMainProject()}-${getEcosystemProductizedBranch()}" -} - -// Git utilities - -void getOrCreateGitBranch(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} already exist ... will not create it. Checking out !" - sh "git checkout ${branch}" - } else { - echo "Branch ${branch} does not exist ... gonna create it" - githubscm.createBranch(branch) - if (!isDryRun()) { - githubscm.pushObject('origin', branch, 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' - - if (!isDryRun()) { - githubscm.commitChanges(commitMsg) - githubscm.pushObject('origin', branch, credentialsId) - } - - sendNotification(notificationMsg) - } else { - println '[WARN] No changes to commit' - } -} - diff --git a/dsl/seed/jenkinsfiles/Jenkinsfile.release.prepare b/dsl/seed/jenkinsfiles/Jenkinsfile.release.prepare index 0a5514e79..12e4c056d 100644 --- a/dsl/seed/jenkinsfiles/Jenkinsfile.release.prepare +++ b/dsl/seed/jenkinsfiles/Jenkinsfile.release.prepare @@ -54,7 +54,6 @@ pipeline { // Update branch config def branchConfig = readYaml file: branchConfigFile branchConfig.repositories = repositories - branchConfig.productized_branch = params.PRODUCTIZED_BRANCH // Disable some environments when branching as they make no sense by default branchConfig.environments.each { envName, envData -> @@ -63,9 +62,6 @@ pipeline { envData.enabled = false // Keep only quarkus-branch } } - if (envData.ids.find { it == 'lts' }) { - envData.enabled = params.PRODUCTIZED_BRANCH // LTS envs depend on param - } } echo "Write dsl branch_config => ${branchConfig}" diff --git a/dsl/seed/jenkinsfiles/Jenkinsfile.seed.main b/dsl/seed/jenkinsfiles/Jenkinsfile.seed.main index 7745c7ea1..462044579 100644 --- a/dsl/seed/jenkinsfiles/Jenkinsfile.seed.main +++ b/dsl/seed/jenkinsfiles/Jenkinsfile.seed.main @@ -43,11 +43,9 @@ pipeline { steps { script { def releaseProjects = readSeedConfig().ecosystem.projects.findAll { ! (it.ignore_release ? it.ignore_release.toBoolean() : false) } - def productizeProjects = readSeedConfig().ecosystem.projects.findAll { ! (it.ignore_productization ? it.ignore_productization.toBoolean() : false) } def envProperties = [ JENKINS_EMAIL_CREDS_ID: readSeedConfig().jenkins.email_creds_id, RELEASE_PROJECTS: releaseProjects.collect { it.name }.join(','), - PRODUCTIZED_PROJECTS: productizeProjects.collect { it.name }.join(','), DEPENDENCY_PROJECTS: readSeedConfig().ecosystem.dependencies.collect { it.name } .join(','), SEED_REPO: "${SEED_REPO}", SEED_AUTHOR: "${SEED_AUTHOR}", diff --git a/dsl/seed/jobs/root_jobs.groovy b/dsl/seed/jobs/root_jobs.groovy index 95a21e80d..f3e3dd006 100644 --- a/dsl/seed/jobs/root_jobs.groovy +++ b/dsl/seed/jobs/root_jobs.groovy @@ -30,8 +30,6 @@ KogitoJobTemplate.createPipelineJob(this, jobParams)?.with { stringParam("${projectName}_VERSION".toUpperCase(), '', "${Utils.getRepoNameCamelCase(projectName)} dependency version which this will depend on") } } - - booleanParam('PRODUCTIZED_BRANCH', false, 'Is the created branch a productized one ?') } environmentVariables { @@ -85,61 +83,3 @@ if (nonMainBranches) { } else { println 'No branches to remove ...' } - -def jobParamsProd = [ - job: [ - name: '0-prepare-productized-branch', - description: 'Prepare productized branch', - ], - git: [ - repository: Utils.getSeedRepo(this), - author: Utils.getSeedAuthor(this), - credentials: Utils.getSeedAuthorCredsId(this), - branch: Utils.getSeedBranch(this), - ], - env: [:], - jenkinsfile: 'dsl/seed/jenkinsfiles/Jenkinsfile.prod.prepare', -] - -List communityReleaseBranches = ALL_BRANCHES.split(',').findAll { it != MAIN_BRANCH_NAME && !it.endsWith('-prod') } -if (communityReleaseBranches) { - KogitoJobTemplate.createPipelineJob(this, jobParamsProd)?.with { - parameters { - 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') - 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') - - booleanParam('DRY_RUN', false, 'If enabled no changes will be applied to remote branches') - } - - environmentVariables { - env('JENKINS_EMAIL_CREDS_ID', Utils.getJenkinsEmailCredsId(this)) - - env('SEED_CONFIG_FILE_GIT_REPOSITORY', "${SEED_CONFIG_FILE_GIT_REPOSITORY}") - env('SEED_CONFIG_FILE_GIT_AUTHOR_NAME', "${SEED_CONFIG_FILE_GIT_AUTHOR_NAME}") - env('SEED_CONFIG_FILE_GIT_AUTHOR_CREDS_ID', "${SEED_CONFIG_FILE_GIT_AUTHOR_CREDS_ID}") - env('SEED_CONFIG_FILE_GIT_BRANCH', "${SEED_CONFIG_FILE_GIT_BRANCH}") - env('SEED_CONFIG_FILE_PATH', "${SEED_CONFIG_FILE_PATH}") - - env('SEED_REPO', Utils.getSeedRepo(this)) - env('SEED_AUTHOR', Utils.getSeedAuthor(this)) - env('SEED_BRANCH', Utils.getSeedBranch(this)) - env('SEED_CREDENTIALS_ID', Utils.getSeedAuthorCredsId(this)) - } - } -} else { - println 'No branches to productize ...' -} \ No newline at end of file diff --git a/dsl/seed/src/main/groovy/org/kie/jenkins/jobdsl/Utils.groovy b/dsl/seed/src/main/groovy/org/kie/jenkins/jobdsl/Utils.groovy index 9514b2bd9..a7598445d 100644 --- a/dsl/seed/src/main/groovy/org/kie/jenkins/jobdsl/Utils.groovy +++ b/dsl/seed/src/main/groovy/org/kie/jenkins/jobdsl/Utils.groovy @@ -48,10 +48,6 @@ class Utils { static boolean hasBindingValuesStartingWith(def script, String keyPrefix) { return getBindingValuesStartingWith(script, keyPrefix).size() > 0 } - - static boolean isProductizedBranch(def script) { - return getBindingValue(script, 'PRODUCTIZED_BRANCH').toBoolean() - } static String getGenerationBranch(def script) { return getBindingValue(script, 'GENERATION_BRANCH') diff --git a/dsl/seed/src/test/groovy/org/kie/jenkins/jobdsl/JobScriptsSpec.groovy b/dsl/seed/src/test/groovy/org/kie/jenkins/jobdsl/JobScriptsSpec.groovy index 555ab0e31..0e7d74138 100644 --- a/dsl/seed/src/test/groovy/org/kie/jenkins/jobdsl/JobScriptsSpec.groovy +++ b/dsl/seed/src/test/groovy/org/kie/jenkins/jobdsl/JobScriptsSpec.groovy @@ -44,7 +44,6 @@ class JobScriptsSpec extends Specification { envVars.put('GENERATION_BRANCH', 'GENERATION_BRANCH') envVars.put('RELEASE_PROJECTS', 'RELEASE_PROJECTS') - envVars.put('PRODUCTIZED_PROJECTS', 'PRODUCTIZED_PROJECTS') envVars.put('DEPENDENCY_PROJECTS', 'DEPENDENCY_PROJECTS') envVars.put('REPO_NAME', 'REPO_NAME') envVars.put('GIT_MAIN_BRANCH', 'GIT_MAIN_BRANCH')