diff --git a/.ci/jenkins/Jenkinsfile.pr.bdd-tests b/.ci/jenkins/Jenkinsfile.pr.bdd-tests deleted file mode 100644 index 10ecfe380..000000000 --- a/.ci/jenkins/Jenkinsfile.pr.bdd-tests +++ /dev/null @@ -1,263 +0,0 @@ -import org.jenkinsci.plugins.workflow.libs.Library - -@Library('jenkins-pipeline-shared-libraries')_ - -changeAuthor = env.ghprbPullAuthorLogin ?: CHANGE_AUTHOR -changeBranch = env.ghprbSourceBranch ?: BRANCH_NAME -changeTarget = env.ghprbTargetBranch ?: CHANGE_TARGET -changeId = env.ghprbPullId ?: CHANGE_ID - -RUNTIMES_DEPLOY = 'kogito-runtimes-deploy' -APPS_DEPLOY = 'kogito-apps-deploy' -EXAMPLES_DEPLOY = 'kogito-examples-deploy' -IMAGES_DEPLOY = 'kogito-images-deploy' -OPERATOR_DEPLOY = 'kogito-operator-deploy' - -// Map of executed jobs -// See https://javadoc.jenkins.io/plugin/workflow-support/org/jenkinsci/plugins/workflow/support/steps/build/RunWrapper.html -// for more options on built job entity -JOBS = [:] - -FAILED_STAGES = [:] -UNSTABLE_STAGES = [:] - -defaultImageParamsPrefix = 'IMAGE' -kogitoImagesParamsPrefix = 'KOGITO_IMAGES' -examplesImagesParamsPrefix = 'EXAMPLES_IMAGES' - -// Should be multibranch pipeline -pipeline { - agent { - label 'rhel8 && !built-in' - } - - environment { - IMAGE_NAME_SUFFIX = "${getPRRepoName()}-pr-${changeId}-bdd-tests" - BUILD_NAME = "${getPRRepoName()}-pr-${changeId}-bdd-tests" - TEMP_TAG = "temp-${env.BUILD_NAME}" - } - - stages { - stage('Initialize') { - steps { - script { - echo "temporary tag is ${env.TEMP_TAG}" - echo "build name is ${env.BUILD_NAME}" - - currentBuild.displayName = env.BUILD_NAME - } - } - } - - stage('Build & Deploy Kogito Runtimes') { - steps { - script { - echo "Call ${RUNTIMES_DEPLOY} job" - def buildParams = getDefaultBuildParams() - addAuthorBranchParamsIfExist(buildParams, 'kogito-runtimes') - - buildJob(RUNTIMES_DEPLOY, buildParams, false) - } - } - post { - failure { - addFailedStage() - } - } - } - - stage('Build & Deploy Kogito Apps') { - steps { - script { - echo "Call ${APPS_DEPLOY} job" - def buildParams = getDefaultBuildParams() - addAuthorBranchParamsIfExist(buildParams, 'kogito-apps') - - buildJob(APPS_DEPLOY, buildParams, false) - } - } - post { - failure { - addFailedStage() - } - } - } - - stage('Build & Deploy Kogito Examples') { - steps { - script { - echo "Call ${EXAMPLES_DEPLOY} job" - def buildParams = getDefaultBuildParams() - addAuthorBranchParamsIfExist(buildParams, 'kogito-examples') - - buildJob(EXAMPLES_DEPLOY, buildParams, false) - } - } - post { - failure { - addFailedStage() - } - } - } - - stage('Build & Deploy Images') { - steps { - script { - echo "Call ${IMAGES_DEPLOY} job" - - def buildParams = getDefaultBuildParams() - addAuthorBranchParamsIfExist(buildParams, 'kogito-images') - addImageBuildParams(buildParams) - addExamplesParams(buildParams) - addAppsParams(buildParams) - - buildJob(IMAGES_DEPLOY, buildParams, false) - } - } - post { - failure { - addFailedStage() - } - } - } - - // We don't build separately the examples images for this pipeline, that will be done as part of the - - stage('Build & Deploy Operator') { - steps { - script { - echo "Call ${OPERATOR_DEPLOY} job" - def buildParams = getDefaultBuildParams() - addAuthorBranchParamsIfExist(buildParams, 'kogito-operator') - addImageBuildParams(buildParams) - addBooleanParam(buildParams, 'SKIP_NATIVE_TESTS', true) // No native tests for PR BDD tests - - // For BDD tests - addImageBuildParams(buildParams, kogitoImagesParamsPrefix) - addImageBuildParams(buildParams, examplesImagesParamsPrefix) - addStringParam(buildParams, constructKey(examplesImagesParamsPrefix, 'CACHE_MODE'), 'never') - addStringParam(buildParams, constructKey(examplesImagesParamsPrefix, 'NAME_PREFIX'), 'examples') - - addExamplesParams(buildParams) - - buildJob(OPERATOR_DEPLOY, buildParams, false) - } - } - post { - failure { - addFailedStage() - } - } - } - } -} - -def buildJob(String jobName, List buildParams, boolean propagate = true) { - echo "Build ${jobName} with params ${buildParams} and propagate = ${propagate}" - - def job = build(job: "./${jobName}", wait: true, parameters: buildParams, propagate: propagate) - JOBS[jobName] = job - - // Set Unstable if we don't propagate and job failed - if (!propagate && !isJobSucceeded(jobName)) { - addUnstableStage() - unstable("Job ${jobName} finished with result ${job.result}") - } - return job -} - -def getJob(String jobName) { - return JOBS[jobName] -} - -boolean isJobSucceeded(String jobName) { - def job = getJob(jobName) - return job ? job.result == 'SUCCESS' : false -} - -void addFailedStage(String jobName = '') { - FAILED_STAGES.put("${STAGE_NAME}", jobName) -} -void addUnstableStage(String jobName = '') { - UNSTABLE_STAGES.put("${STAGE_NAME}", jobName) -} - -List getDefaultBuildParams() { - List params = [] - addStringParam(params, 'DISPLAY_NAME', env.BUILD_NAME) - return params -} - -boolean doesBranchExist(String repo, String author, String branch) { - return githubscm.getRepositoryScm(repo, author, branch) != null -} - -void addAuthorBranchParamsIfExist(List params, String repo, String targetBranch = '') { - targetBranch = targetBranch ?: changeTarget - if (doesBranchExist(repo, changeAuthor, changeBranch)) { - addStringParam(params, 'GIT_AUTHOR', changeAuthor) - addStringParam(params, 'BUILD_BRANCH_NAME', changeBranch) - // set build branch to kiegroup's version branch - } else if (targetBranch != 'main' && doesBranchExist(repo, 'kiegroup', targetBranch)) { - addStringParam(params, 'BUILD_BRANCH_NAME', targetBranch) - } -} - -void addAppsParams(List buildParams) { - def author = '' - def branch = '' - if (doesBranchExist('kogito-apps', changeAuthor, changeBranch)) { - author = changeAuthor - branch = changeBranch - } else if (doesBranchExist('kogito-apps', 'kiegroup', changeTarget)) { - author = 'kiegroup' - branch = changeTarget - } else { - author = 'kiegroup' - branch = 'main' - } - addStringParam(buildParams, 'APPS_URI', "https://github.com/${author}/kogito-apps") - addStringParam(buildParams, 'APPS_REF', branch) -} - -void addExamplesParams(List buildParams) { - def author = '' - def branch = '' - if (doesBranchExist('kogito-examples', changeAuthor, changeBranch)) { - author = changeAuthor - branch = changeBranch - } else if (doesBranchExist('kogito-examples', 'kiegroup', changeTarget)) { - author = 'kiegroup' - branch = changeTarget - } else { - author = 'kiegroup' - branch = 'main' - } - addStringParam(buildParams, 'EXAMPLES_URI', "https://github.com/${author}/kogito-examples") - addStringParam(buildParams, 'EXAMPLES_REF', branch) -} - -void addImageBuildParams(List buildParams, String paramsPrefix = defaultImageParamsPrefix) { - addBooleanParam(buildParams, constructKey(paramsPrefix, 'USE_OPENSHIFT_REGISTRY'), true) - addStringParam(buildParams, constructKey(paramsPrefix, 'REGISTRY_CREDENTIALS'), env.IMAGE_REGISTRY_CREDENTIALS) - addStringParam(buildParams, constructKey(paramsPrefix, 'REGISTRY'), env.IMAGE_REGISTRY) - addStringParam(buildParams, constructKey(paramsPrefix, 'NAMESPACE'), env.IMAGE_NAMESPACE) - addStringParam(buildParams, constructKey(paramsPrefix, 'NAME_SUFFIX'), env.IMAGE_NAME_NIGHTLY_SUFFIX) - addStringParam(buildParams, constructKey(paramsPrefix, 'TAG'), env.TEMP_TAG) -} - -void addStringParam(List params, String key, String value) { - params.add(string(name: key, value: value)) -} - -void addBooleanParam(List params, String key, boolean value) { - params.add(booleanParam(name: key, value: value)) -} - -String getPRRepoName() { - return env.ghprbGhRepository.split('/')[1] -} - -String constructKey(String prefix, String paramId) { - return prefix ? "${prefix}_${paramId}" : paramId -} diff --git a/.ci/jenkins/config/branch.yaml b/.ci/jenkins/config/branch.yaml index a4bf10534..8d907eb9f 100644 --- a/.ci/jenkins/config/branch.yaml +++ b/.ci/jenkins/config/branch.yaml @@ -47,10 +47,6 @@ environments: - quarkus - lts - prod - kogito-bdd: - auto_generation: false - ids: - - cloud sonarcloud: auto_generation: false env_vars: @@ -119,10 +115,6 @@ maven: quarkus_platform_repository: url: https://repository.jboss.org/nexus/content/repositories/kogito-internal-repository/ creds_id: kogito-internal-nexus-creds - pr_checks: - repository: - url: https://bxms-qe.rhev-ci-vms.eng.rdu2.redhat.com:8443/nexus/content/repositories/kogito-runtimes-pr-full-testing/ - creds_id: unpacks-zip-on-qa-nexus cloud: image: registry_credentials_nightly: nightly_kogito diff --git a/.ci/jenkins/dsl/jobs.groovy b/.ci/jenkins/dsl/jobs.groovy index c964af78b..b4adf0d34 100644 --- a/.ci/jenkins/dsl/jobs.groovy +++ b/.ci/jenkins/dsl/jobs.groovy @@ -11,9 +11,6 @@ boolean isMainStream() { return Utils.getStream(this) == 'main' } -// PRs -setupKogitoRuntimesBDDPrJob() - // Tools setupUpdateJenkinsDependenciesJob() if (isMainStream()) { @@ -64,21 +61,6 @@ setupReleaseCloudJob() // Methods ///////////////////////////////////////////////////////////////// -void setupKogitoRuntimesBDDPrJob() { - def jobParams = JobParamsUtils.getBasicJobParamsWithEnv(this, '0-runtimes-bdd-testing', JobType.PULL_REQUEST, 'kogito-bdd', "${JENKINSFILE_PATH}/Jenkinsfile.pr.bdd-tests", 'Run on demand BDD tests from runtimes repository') - jobParams.git.project_url = "https://github.com/${GIT_AUTHOR_NAME}/kogito-runtimes/" - jobParams.git.repo_url = "https://github.com/${GIT_AUTHOR_NAME}/${jobParams.git.repository}/" - jobParams.pr = [ - run_only_for_branches: [ jobParams.git.branch ], - checkout_branch : '${ghprbTargetBranch}', - trigger_phrase : '.*[j|J]enkins,? run BDD[ tests]?.*', - trigger_phrase_only: true, - commitContext: 'BDD' - ] - jobParams.disable_concurrent = true - KogitoJobTemplate.createPRJob(this, jobParams) -} - void setupCleanOldNamespacesToolsJob() { def jobParams = JobParamsUtils.getBasicJobParams(this, 'kogito-clean-old-namespaces', JobType.TOOLS, "${JENKINSFILE_PATH}/Jenkinsfile.tools.clean-old-namespaces") jobParams.triggers = [ cron : '@midnight' ]