diff --git a/.ci/jenkins/Jenkinsfile b/.ci/jenkins/Jenkinsfile index 9216cfe76..0ba9676a4 100644 --- a/.ci/jenkins/Jenkinsfile +++ b/.ci/jenkins/Jenkinsfile @@ -4,10 +4,6 @@ pipeline { agent { label 'ubuntu' } - tools { - maven env.BUILD_MAVEN_TOOL - jdk env.BUILD_JDK_TOOL - } options { timeout(time: 120, unit: 'MINUTES') } @@ -97,7 +93,7 @@ String[] getImages() { if (env.IMAGES_LIST) { return env.IMAGES_LIST.split(',') } - return util.runWithPythonVirtualEnv("make list | tr '\\n' ','", 'cekit', true).trim().split(',') + return sh(returnStdout: true, script: "make list | tr '\\n' ','").trim().split(',') } String getChangeAuthor() { diff --git a/.ci/jenkins/Jenkinsfile.build-image b/.ci/jenkins/Jenkinsfile.build-image index 2d43df742..f13a64043 100644 --- a/.ci/jenkins/Jenkinsfile.build-image +++ b/.ci/jenkins/Jenkinsfile.build-image @@ -4,18 +4,15 @@ QUAY_REGISTRY = 'quay.io' pipeline { agent { - label 'ubuntu' - } - tools { - maven env.BUILD_MAVEN_TOOL - jdk env.BUILD_JDK_TOOL + docker { + image env.AGENT_DOCKER_BUILDER_IMAGE + args env.AGENT_DOCKER_BUILDER_ARGS + } } options { timeout(time: 120, unit: 'MINUTES') } environment { - CI = true - // Linked to node label // Use docker due to multiplatform build CONTAINER_ENGINE = 'docker' @@ -248,7 +245,7 @@ String getBuiltImageTag(String imageTag = '') { } void runPythonCommand(String cmd, boolean stdout = false) { - return util.runWithPythonVirtualEnv(cmd, 'cekit', stdout) + return sh(returnStdout: stdout, script: cmd) } //////////////////////////////////////////////////////////////////////// diff --git a/.ci/jenkins/Jenkinsfile.deploy b/.ci/jenkins/Jenkinsfile.deploy index ec41815ac..83697af7a 100644 --- a/.ci/jenkins/Jenkinsfile.deploy +++ b/.ci/jenkins/Jenkinsfile.deploy @@ -10,13 +10,10 @@ TEST_FAILED_IMAGES = [] pipeline { agent { - label 'ubuntu' - } - - // Needed for local build - tools { - maven env.BUILD_MAVEN_TOOL - jdk env.BUILD_JDK_TOOL + docker { + image env.AGENT_DOCKER_BUILDER_IMAGE + args env.AGENT_DOCKER_BUILDER_ARGS + } } options { @@ -421,7 +418,7 @@ String[] getImages() { } void runPythonCommand(String cmd, boolean stdout = false) { - return util.runWithPythonVirtualEnv(cmd, 'cekit', stdout) + return sh(returnStdout: stdout, script: cmd) } String getQuarkusPlatformVersion() { diff --git a/.ci/jenkins/Jenkinsfile.promote b/.ci/jenkins/Jenkinsfile.promote index 99cc7e81e..9bf8b4994 100644 --- a/.ci/jenkins/Jenkinsfile.promote +++ b/.ci/jenkins/Jenkinsfile.promote @@ -5,24 +5,21 @@ deployProperties = [:] pipeline { agent { - label 'ubuntu' + docker { + image env.AGENT_DOCKER_BUILDER_IMAGE + args env.AGENT_DOCKER_BUILDER_ARGS + } } options { timeout(time: 120, unit: 'MINUTES') } - // parameters { - // For parameters, check into ./dsl/jobs.groovy file - // } environment { - // Static env is defined into ./dsl/jobs.groovy file - KOGITO_CI_EMAIL_TO = credentials("${JENKINS_EMAIL_CREDS_ID}") - // Linked to node label - CONTAINER_ENGINE = 'podman' - CONTAINER_ENGINE_TLS_OPTIONS = '--tls-verify=false' + CONTAINER_ENGINE = 'docker' + CONTAINER_ENGINE_TLS_OPTIONS = '' OPENSHIFT_API = credentials('OPENSHIFT_API') OPENSHIFT_REGISTRY = credentials('OPENSHIFT_REGISTRY') @@ -359,5 +356,5 @@ String[] getImages() { } void runPythonCommand(String cmd, boolean stdout = false) { - return util.runWithPythonVirtualEnv(cmd, 'cekit', stdout) + return sh(returnStdout: stdout, script: cmd) } diff --git a/.ci/jenkins/Jenkinsfile.setup-branch b/.ci/jenkins/Jenkinsfile.setup-branch index 91508ce5d..182689cb0 100644 --- a/.ci/jenkins/Jenkinsfile.setup-branch +++ b/.ci/jenkins/Jenkinsfile.setup-branch @@ -3,29 +3,18 @@ import org.jenkinsci.plugins.workflow.libs.Library pipeline { agent { - label 'ubuntu' - } - - // Needed for local build - tools { - maven env.BUILD_MAVEN_TOOL - jdk env.BUILD_JDK_TOOL + docker { + image env.AGENT_DOCKER_BUILDER_IMAGE + args env.AGENT_DOCKER_BUILDER_ARGS + } } options { timeout(time: 120, unit: 'MINUTES') } - // parameters { - // For parameters, check into ./dsl/jobs.groovy file - // } - environment { - // Static env is defined into ./dsl/jobs.groovy file - KOGITO_CI_EMAIL_TO = credentials("${JENKINS_EMAIL_CREDS_ID}") - - JAVA_HOME = "${GRAALVM_HOME}" } stages { @@ -182,5 +171,5 @@ String getCleanedReleaseNotes() { } void runPythonCommand(String cmd, boolean stdout = false) { - return util.runWithPythonVirtualEnv(cmd, 'cekit', stdout) + return sh(returnStdout: stdout, script: cmd) } \ No newline at end of file diff --git a/.ci/jenkins/Jenkinsfile.update-prod-version b/.ci/jenkins/Jenkinsfile.update-prod-version deleted file mode 100644 index de833ebfb..000000000 --- a/.ci/jenkins/Jenkinsfile.update-prod-version +++ /dev/null @@ -1,103 +0,0 @@ -@Library('jenkins-pipeline-shared-libraries')_ - -pipeline { - agent { - label 'ubuntu' - } - - options { - timeout(time: 30, unit: 'MINUTES') - } - - // parameters { - // For parameters, check into ./dsl/jobs.groovy file - // } - - environment { - // Static env is defined into ./dsl/jobs.groovy file - - PR_BRANCH_HASH = "${util.generateHash(10)}" - } - - stages { - stage('Initialization') { - steps { - script { - assert getProdProjectVersion() - assert getJiraNumber() - - currentBuild.displayName = getProdProjectVersion() - - deleteDir() - checkout(githubscm.resolveRepository(getRepoName(), getGitAuthor(), getBuildBranch(), false)) - } - } - } - stage('Prepare for PR') { - steps { - script { - githubscm.createBranch(getPRBranch()) - } - } - } - stage('Update prod version') { - when { - expression { return getProdProjectVersion() != '' } - } - steps { - script { - sh "python3 scripts/manage-kogito-version.py --bump-to ${getProdProjectVersion()} --confirm --prod" - } - } - } - stage('Create PR') { - steps { - script { - String commitMsg = "[${getJiraNumber()}] Update product version to ${getProdProjectVersion()}" - if (githubscm.isThereAnyChanges()) { - githubscm.commitChanges(commitMsg) - } else { - error 'No update version can be done' - } - githubscm.pushObject('origin', getPRBranch(), getGitAuthorCredsID()) - String prLink = githubscm.createPR(commitMsg, 'Please review and merge', getBuildBranch(), getGitAuthorCredsID()) - - echo "Created PR ${prLink}" - } - } - } - } - post { - cleanup { - cleanWs() - } - } -} - -String getRepoName() { - return "${REPO_NAME}" -} - -String getBuildBranch() { - return "${BUILD_BRANCH_NAME}" -} - -String getGitAuthor() { - return "${GIT_AUTHOR}" -} - -String getGitAuthorCredsID() { - return env.AUTHOR_CREDS_ID -} - -String getPRBranch() { - return "${getProdProjectVersion() ?: getBuildBranch()}-${env.PR_BRANCH_HASH}" -} - -String getProdProjectVersion() { - return "${PROD_PROJECT_VERSION}" -} - -String getJiraNumber() { - return "${JIRA_NUMBER}" -} \ No newline at end of file diff --git a/.ci/jenkins/dsl/jobs.groovy b/.ci/jenkins/dsl/jobs.groovy index 5ae1088be..b019fb491 100644 --- a/.ci/jenkins/dsl/jobs.groovy +++ b/.ci/jenkins/dsl/jobs.groovy @@ -17,7 +17,8 @@ import org.kie.jenkins.jobdsl.Utils jenkins_path = '.ci/jenkins' // PR checks -setupPrJob() +// TODO create PR job with branch source plugin +// setupPrJob() // Init branch createSetupBranchJob() @@ -40,28 +41,27 @@ setupQuarkusUpdateJob() void setupPrJob() { setupBuildImageJob(JobType.PULL_REQUEST) - // TODO create PR job with branch source plugin - // def jobParams = JobParamsUtils.getBasicJobParams(this, 'kogito-images', JobType.PULL_REQUEST, "${jenkins_path}/Jenkinsfile", "Kogito Images PR check") - // JobParamsUtils.setupJobParamsDefaultMavenConfiguration(this, jobParams) - // jobParams.pr.putAll([ - // run_only_for_branches: [ "${GIT_BRANCH}" ], - // disable_status_message_error: true, - // disable_status_message_failure: true, - // commitContext: 'Retrieve and Launch Image Checks', - // contextShowtestResults: false, - // ]) - // if (Utils.hasBindingValue(this, 'CLOUD_IMAGES')) { - // jobParams.env.put('IMAGES_LIST', Utils.getBindingValue(this, 'CLOUD_IMAGES')) - // } - // jobParams.env.putAll([ - // AUTHOR_CREDS_ID: "${GIT_AUTHOR_CREDENTIALS_ID}", - // ]) - // KogitoJobTemplate.createPRJob(this, jobParams) + def jobParams = JobParamsUtils.getBasicJobParams(this, 'kogito-images', JobType.PULL_REQUEST, "${jenkins_path}/Jenkinsfile", "Kogito Images PR check") + JobParamsUtils.setupJobParamsAgentDockerBuilderImageConfiguration(this, jobParams) + jobParams.pr.putAll([ + run_only_for_branches: [ "${GIT_BRANCH}" ], + disable_status_message_error: true, + disable_status_message_failure: true, + commitContext: 'Retrieve and Launch Image Checks', + contextShowtestResults: false, + ]) + if (Utils.hasBindingValue(this, 'CLOUD_IMAGES')) { + jobParams.env.put('IMAGES_LIST', Utils.getBindingValue(this, 'CLOUD_IMAGES')) + } + jobParams.env.putAll([ + AUTHOR_CREDS_ID: "${GIT_AUTHOR_CREDENTIALS_ID}", + ]) + KogitoJobTemplate.createPRJob(this, jobParams) } void createSetupBranchJob() { def jobParams = JobParamsUtils.getBasicJobParams(this, 'kogito-images', JobType.SETUP_BRANCH, "${jenkins_path}/Jenkinsfile.setup-branch", 'Kogito Images Init Branch') - JobParamsUtils.setupJobParamsDefaultMavenConfiguration(this, jobParams) + JobParamsUtils.setupJobParamsAgentDockerBuilderImageConfiguration(this, jobParams) jobParams.env.putAll([ REPO_NAME: 'kogito-images', GIT_AUTHOR: "${GIT_AUTHOR_NAME}", @@ -91,7 +91,7 @@ void setupDeployJob(JobType jobType) { setupBuildImageJob(jobType) def jobParams = JobParamsUtils.getBasicJobParams(this, 'kogito-images-deploy', jobType, "${jenkins_path}/Jenkinsfile.deploy", 'Kogito Images Deploy') - JobParamsUtils.setupJobParamsDefaultMavenConfiguration(this, jobParams) + JobParamsUtils.setupJobParamsAgentDockerBuilderImageConfiguration(this, jobParams) jobParams.env.putAll([ PROPERTIES_FILE_NAME: 'deployment.properties', @@ -152,7 +152,7 @@ void setupBuildImageJob(JobType jobType) { // Use jenkinsfile from the build branch jobParams.git.author = '${SOURCE_AUTHOR}' jobParams.git.branch = '${SOURCE_BRANCH}' - JobParamsUtils.setupJobParamsDefaultMavenConfiguration(this, jobParams) + JobParamsUtils.setupJobParamsAgentDockerBuilderImageConfiguration(this, jobParams) jobParams.env.putAll([ MAX_REGISTRY_RETRIES: 3, TARGET_AUTHOR: Utils.getGitAuthor(this), // In case of a PR to merge with target branch @@ -199,6 +199,7 @@ void setupBuildImageJob(JobType jobType) { void setupPromoteJob(JobType jobType) { def jobParams = JobParamsUtils.getBasicJobParams(this, 'kogito-images-promote', jobType, "${jenkins_path}/Jenkinsfile.promote", 'Kogito Images Promote') + JobParamsUtils.setupJobParamsAgentDockerBuilderImageConfiguration(this, jobParams) jobParams.env.putAll([ REPO_NAME: 'kogito-images', PROPERTIES_FILE_NAME: 'deployment.properties', @@ -256,24 +257,6 @@ void setupPromoteJob(JobType jobType) { } } -void setupProdUpdateVersionJob() { - def jobParams = JobParamsUtils.getBasicJobParams(this, 'kogito-images-update-prod-version', JobType.TOOLS, "${jenkins_path}/Jenkinsfile.update-prod-version", 'Update prod version for Kogito Images') - jobParams.env.putAll([ - REPO_NAME: 'kogito-images', - - BUILD_BRANCH_NAME: "${GIT_BRANCH}", - GIT_AUTHOR: "${GIT_AUTHOR_NAME}", - AUTHOR_CREDS_ID: "${GIT_AUTHOR_CREDENTIALS_ID}", - GITHUB_TOKEN_CREDS_ID: "${GIT_AUTHOR_TOKEN_CREDENTIALS_ID}", - ]) - KogitoJobTemplate.createPipelineJob(this, jobParams)?.with { - parameters { - stringParam('JIRA_NUMBER', '', 'KIECLOUD-XXX or RHPAM-YYYY or else. This will be added to the commit and PR.') - stringParam('PROD_PROJECT_VERSION', '', 'Which version to set ?') - } - } -} - void setupQuarkusUpdateJob() { KogitoJobUtils.createQuarkusUpdateToolsJob(this, 'kogito-images', [:], [:], [], [ "source ~/virtenvs/cekit/bin/activate && python3 scripts/update-repository.py --quarkus-platform-version %new_version%"