From 7ccd9efd5f7408038e7881e09144ee2e573ba599 Mon Sep 17 00:00:00 2001 From: Jan Stastny Date: Fri, 26 Jul 2024 12:00:18 +0200 Subject: [PATCH] Adjust development branch (#632) * kie-issues#574 Initial ASF Jenkins CI Setup (#607) Co-authored-by: jstastny-cz * kie-issues#587 abort stale builds (#608) Co-authored-by: jstastny-cz * kie-issues#643: fix PR check buildchain configuration * kie-issues#667: fix cleanup and settingsXml handling (#613) * kie-issues#667: fix cleanup and settingsXml handling * adjust also MavenCommands passed to maven library methods --------- Co-authored-by: jstastny-cz * 8.x kie-issues#674: update GHA references (#614) * kie-issues#674: update GHA references * change surefire action --------- Co-authored-by: jstastny-cz * kie-issues#727: define push GH tokens for jenkins * 8.x kie-issues#767: set user config for git * NO-ISSUE: fix docker agent config * NO-ISSUE: adjust branch mapping * NO-ISSUE: apache transfer leftovers * parameterize buildchain file url --------- Co-authored-by: jstastny-cz --- .ci/environments/common/update_quarkus.sh | 2 +- .ci/jenkins/Jenkinsfile | 44 ++++++++++++++ .ci/jenkins/Jenkinsfile.setup-branch | 57 +++++++++++-------- .ci/jenkins/dsl/jobs.groovy | 9 ++- .ci/jenkins/dsl/test.sh | 8 +-- .github/pull_request_template.md | 6 +- .github/workflows/pull_request.yml | 6 -- README.adoc | 4 +- .../src/main/assembly/resources/ReadMe.txt | 4 +- .../resources/META-INF/resources/index.html | 2 +- hello-world/README.adoc | 4 +- technology/java-activemq-quarkus/README.adoc | 4 +- technology/java-spring-boot/README.adoc | 4 +- technology/kotlin-quarkus/README.adoc | 6 +- technology/kubernetes/README.adoc | 2 +- use-cases/call-center/README.adoc | 6 +- use-cases/employee-scheduling/README.adoc | 6 +- use-cases/facility-location/README.adoc | 6 +- use-cases/maintenance-scheduling/README.adoc | 6 +- use-cases/order-picking/README.adoc | 6 +- use-cases/school-timetabling/README.adoc | 6 +- use-cases/vaccination-scheduling/README.adoc | 6 +- use-cases/vehicle-routing/README.adoc | 6 +- 23 files changed, 127 insertions(+), 83 deletions(-) create mode 100644 .ci/jenkins/Jenkinsfile diff --git a/.ci/environments/common/update_quarkus.sh b/.ci/environments/common/update_quarkus.sh index 6ac5e81e5..2c2e70649 100755 --- a/.ci/environments/common/update_quarkus.sh +++ b/.ci/environments/common/update_quarkus.sh @@ -3,7 +3,7 @@ set -euo pipefail mvn_cmd="mvn ${BUILD_MVN_OPTS:-} ${BUILD_MVN_OPTS_QUARKUS_UPDATE:-}" -source <(curl -s https://github.com/raw/kiegroup/kogito-pipelines/main/dsl/seed/scripts/install_quarkus.sh) +source <(curl -s https://github.com/raw/apache/incubator-kie-kogito-pipelines/main/dsl/seed/scripts/install_quarkus.sh) echo "Update project with Quarkus version ${QUARKUS_VERSION}" diff --git a/.ci/jenkins/Jenkinsfile b/.ci/jenkins/Jenkinsfile new file mode 100644 index 000000000..7cb240996 --- /dev/null +++ b/.ci/jenkins/Jenkinsfile @@ -0,0 +1,44 @@ +@Library('jenkins-pipeline-shared-libraries')_ + +pr_check_script = null + +pipeline { + agent { + label 'ubuntu' + } + options { + timestamps() + timeout(time: 720, unit: 'MINUTES') + disableConcurrentBuilds(abortPrevious: true) + } + environment { + BUILDCHAIN_PROJECT = 'apache/incubator-kie-optaplanner-quickstarts' + BUILDCHAIN_CONFIG_REPO = 'incubator-kie-optaplanner' + BUILDCHAIN_CONFIG_FILE_PATH = '.ci/buildchain-config-pr-cdb.yaml' + + OPTAPLANNER_BUILD_MVN_OPTS_UPSTREAM = '-Dfull' + BUILD_MVN_OPTS_CURRENT = '-Dfull' + } + stages { + stage('Initialize') { + steps { + script { + // load `pr_check.groovy` file from kogito-pipelines:main + dir('kogito-pipelines') { + checkout(githubscm.resolveRepository('incubator-kie-kogito-pipelines', 'apache', 'main', false, 'kie-ci')) + pr_check_script = load 'dsl/scripts/pr_check.groovy' + } + } + } + } + stage('PR check') { + steps { + script { + dir('kogito-pipelines') { + pr_check_script.launch() + } + } + } + } + } +} \ No newline at end of file diff --git a/.ci/jenkins/Jenkinsfile.setup-branch b/.ci/jenkins/Jenkinsfile.setup-branch index 75210370e..4fbdd771c 100644 --- a/.ci/jenkins/Jenkinsfile.setup-branch +++ b/.ci/jenkins/Jenkinsfile.setup-branch @@ -3,16 +3,15 @@ import org.jenkinsci.plugins.workflow.libs.Library import org.kie.jenkins.MavenCommand -optaplannerRepo = 'optaplanner' +optaplannerRepo = 'incubator-kie-optaplanner' pipeline { agent { - label util.avoidFaultyNodes('kie-rhel8 && !built-in') - } - - tools { - maven env.BUILD_MAVEN_TOOL - jdk env.BUILD_JDK_TOOL + docker { + image env.AGENT_DOCKER_BUILDER_IMAGE + args env.AGENT_DOCKER_BUILDER_ARGS + label util.avoidFaultyNodes('ubuntu') + } } options { @@ -20,30 +19,22 @@ pipeline { timeout(time: 60, unit: 'MINUTES') } - // parameters { - // For parameters, check into ./dsl/jobs.groovy file - // } - environment { - // Static env is defined into ./dsl/jobs.groovy file - OPTAPLANNER_CI_EMAIL_TO = credentials("${JENKINS_EMAIL_CREDS_ID}") - - // Keep here for visitibility - MAVEN_OPTS = '-Xms1024m -Xmx4g' } stages { stage('Initialize') { steps { script { - cleanWs() + cleanWs(disableDeferredWipeout: true) if (params.DISPLAY_NAME) { currentBuild.displayName = params.DISPLAY_NAME } - checkoutRepo(optaplannerRepo, getBuildBranch()) + optaplannerBranch = getBuildBranch() == 'development' ? 'main' : getBuildBranch() + checkoutRepo(optaplannerRepo, optaplannerBranch) checkoutRepo(getRepoName(), getBuildBranch()) } } @@ -51,17 +42,34 @@ pipeline { stage('Build OptaPlanner parents') { steps { script { - getMavenCommand(optaplannerRepo) - .withOptions(['-U', '-pl org.optaplanner:optaplanner-build-parent,org.optaplanner:optaplanner-bom,org.optaplanner:optaplanner-operator', '-am']) - .run('clean install') + configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){ + getMavenCommand(optaplannerRepo) + .withOptions([ + '-U', + '-pl org.optaplanner:optaplanner-build-parent,org.optaplanner:optaplanner-bom,org.optaplanner:optaplanner-operator', + '-am' + ]) + .withSettingsXmlFile(MAVEN_SETTINGS_FILE) + .run('clean install') + } } } } stage('Update project version') { steps { script { - maven.mvnSetVersionProperty(getMavenCommand(getRepoName()), 'version.org.optaplanner', getOptaPlannerVersion()) - maven.mvnVersionsUpdateParentAndChildModules(getMavenCommand(getRepoName()), getOptaPlannerVersion(), true) + configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){ + maven.mvnSetVersionProperty( + getMavenCommand(getRepoName()).withSettingsXmlFile(MAVEN_SETTINGS_FILE), + 'version.org.optaplanner', + getOptaPlannerVersion() + ) + maven.mvnVersionsUpdateParentAndChildModules( + getMavenCommand(getRepoName()).withSettingsXmlFile(MAVEN_SETTINGS_FILE), + getOptaPlannerVersion(), + true + ) + } dir(getRepoName()) { sh "find . -name build.gradle -exec sed -i -E 's/def optaplannerVersion = \"[^\"\\s]+\"/def optaplannerVersion = \"${getOptaPlannerVersion()}\"/' {} \\;" @@ -95,7 +103,7 @@ pipeline { } cleanup { script { - util.cleanNode('docker') + util.cleanNode() } } } @@ -146,6 +154,5 @@ String getGitAuthorPushCredsId() { MavenCommand getMavenCommand(String directory) { return new MavenCommand(this, ['-fae', '-ntp']) - .withSettingsXmlId(env.MAVEN_SETTINGS_CONFIG_FILE_ID) .inDirectory(directory) } diff --git a/.ci/jenkins/dsl/jobs.groovy b/.ci/jenkins/dsl/jobs.groovy index ae461f8ad..481a5d720 100644 --- a/.ci/jenkins/dsl/jobs.groovy +++ b/.ci/jenkins/dsl/jobs.groovy @@ -2,10 +2,10 @@ * This file is describing all the Jenkins jobs in the DSL format (see https://plugins.jenkins.io/job-dsl/) * needed by the Kogito pipelines. * -* The main part of Jenkins job generation is defined into the https://github.com/kiegroup/kogito-pipelines repository. +* The main part of Jenkins job generation is defined into the https://github.com/apache/incubator-kie-kogito-pipelines repository. * * This file is making use of shared libraries defined in -* https://github.com/kiegroup/kogito-pipelines/tree/main/dsl/seed/src/main/groovy/org/kie/jenkins/jobdsl. +* https://github.com/apache/incubator-kie-kogito-pipelines/tree/main/dsl/seed/src/main/groovy/org/kie/jenkins/jobdsl. */ import org.kie.jenkins.jobdsl.model.JobType @@ -35,7 +35,7 @@ Map getMultijobPRConfig() { } // Optaplanner PR checks -KogitoJobUtils.createAllEnvironmentsPerRepoPRJobs(this) { jobFolder -> getMultijobPRConfig() } +Utils.isMainBranch(this) && KogitoJobTemplate.createPullRequestMultibranchPipelineJob(this, "${jenkins_path}/Jenkinsfile") // Init branch createSetupBranchJob() @@ -62,9 +62,8 @@ void setupSpecificBuildChainNightlyJob(String envName) { void createSetupBranchJob() { def jobParams = JobParamsUtils.getBasicJobParams(this, 'optaplanner-quickstarts', JobType.SETUP_BRANCH, "${jenkins_path}/Jenkinsfile.setup-branch", 'OptaPlanner Quickstarts Setup Branch') - JobParamsUtils.setupJobParamsDefaultMavenConfiguration(this, jobParams) + JobParamsUtils.setupJobParamsAgentDockerBuilderImageConfiguration(this, jobParams) jobParams.env.putAll([ - REPO_NAME: 'optaplanner-quickstarts', JENKINS_EMAIL_CREDS_ID: "${JENKINS_EMAIL_CREDS_ID}", GIT_AUTHOR: "${GIT_AUTHOR_NAME}", diff --git a/.ci/jenkins/dsl/test.sh b/.ci/jenkins/dsl/test.sh index 1dd3b10fe..5449b2638 100755 --- a/.ci/jenkins/dsl/test.sh +++ b/.ci/jenkins/dsl/test.sh @@ -22,13 +22,13 @@ fi git_author="$(echo ${git_url} | awk -F"${git_server_url}" '{print $2}' | awk -F. '{print $1}' | awk -F/ '{print $1}')" -export DSL_DEFAULT_MAIN_CONFIG_FILE_REPO="${git_author}"/optaplanner -export DSL_DEFAULT_FALLBACK_MAIN_CONFIG_FILE_REPO=kiegroup/optaplanner +export DSL_DEFAULT_MAIN_CONFIG_FILE_REPO="${git_author}"/incubator-kie-optaplanner +export DSL_DEFAULT_FALLBACK_MAIN_CONFIG_FILE_REPO=apache/incubator-kie-optaplanner export DSL_DEFAULT_MAIN_CONFIG_FILE_PATH=.ci/jenkins/config/main.yaml -export DSL_DEFAULT_BRANCH_CONFIG_FILE_REPO="${git_author}"/optaplanner +export DSL_DEFAULT_BRANCH_CONFIG_FILE_REPO="${git_author}"/incubator-kie-optaplanner file=$(mktemp) # For more usage of the script, use ./test.sh -h -curl -o ${file} https://github.com/raw/kiegroup/kogito-pipelines/main/dsl/seed/scripts/seed_test.sh +curl -o ${file} https://github.com/raw/apache/incubator-kie-kogito-pipelines/main/dsl/seed/scripts/seed_test.sh chmod u+x ${file} ${file} $@ \ No newline at end of file diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index b4097a1c5..1a728734f 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -19,11 +19,11 @@ and also the external https://github.com/quarkusio/quarkus-quickstarts/tree/main ### Referenced pull requests +changes that span multiple KIE repositories and depend on each other. --> diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 7970ba637..38fc02ae5 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -31,12 +31,6 @@ jobs: - name: Support long paths if: ${{ matrix.os == 'windows-latest' }} uses: apache/incubator-kie-kogito-pipelines/.ci/actions/long-paths@main - - name: Sets the migration env variable on Windows - if: runner.os == 'Windows' - run: echo "MIGRATE_TO_9=${{ github.base_ref == 'development' }}" >> $env:GITHUB_ENV - - name: Sets the migration env variable on Linux - if: runner.os != 'Windows' - run: echo "MIGRATE_TO_9=${{ github.base_ref == 'development' }}" >> $GITHUB_ENV - name: Java and Maven Setup uses: apache/incubator-kie-kogito-pipelines/.ci/actions/maven@main with: diff --git a/README.adoc b/README.adoc index b1f9ead37..6b08ddba8 100644 --- a/README.adoc +++ b/README.adoc @@ -33,8 +33,8 @@ Run the https://www.optaplanner.org/[OptaPlanner] quickstarts now: + [source, shell] ---- -$ git clone https://github.com/kiegroup/optaplanner-quickstarts.git -$ cd optaplanner-quickstarts +$ git clone https://github.com/apache/incubator-kie-optaplanner-quickstarts.git +$ cd incubator-kie-optaplanner-quickstarts $ ./runQuickstartsFromSource.sh ---- diff --git a/build/optaplanner-distribution/src/main/assembly/resources/ReadMe.txt b/build/optaplanner-distribution/src/main/assembly/resources/ReadMe.txt index 44701c8f8..bbde96a83 100644 --- a/build/optaplanner-distribution/src/main/assembly/resources/ReadMe.txt +++ b/build/optaplanner-distribution/src/main/assembly/resources/ReadMe.txt @@ -12,7 +12,7 @@ On Windows: Run the quickstarts in IDE ---------------------------- -Please refer to https://github.com/kiegroup/optaplanner-quickstarts/blob/stable/README.adoc. +Please refer to https://github.com/apache/incubator-kie-optaplanner-quickstarts/blob/stable/README.adoc. Run the examples ---------------- @@ -56,7 +56,7 @@ Sources ------- But to build from sources, pull the sources with git: - https://github.com/kiegroup/optaplanner + https://github.com/apache/incubator-kie-optaplanner Backwards compatibility ----------------------- diff --git a/build/quickstarts-showcase/src/main/resources/META-INF/resources/index.html b/build/quickstarts-showcase/src/main/resources/META-INF/resources/index.html index 3fe909457..226022874 100644 --- a/build/quickstarts-showcase/src/main/resources/META-INF/resources/index.html +++ b/build/quickstarts-showcase/src/main/resources/META-INF/resources/index.html @@ -14,7 +14,7 @@