diff --git a/.ci/jenkins/Jenkinsfile b/.ci/jenkins/Jenkinsfile new file mode 100644 index 0000000000..af6866a3c7 --- /dev/null +++ b/.ci/jenkins/Jenkinsfile @@ -0,0 +1,40 @@ +@Library('jenkins-pipeline-shared-libraries')_ + +pr_check_script = null + +pipeline { + agent { + label env.ADDITIONAL_LABEL?.trim() ?: 'ubuntu' + } + options { + timestamps() + timeout(time: env.ADDITIONAL_TIMEOUT?.trim() ?: '180', unit: 'MINUTES') + } + environment { + BUILDCHAIN_PROJECT = 'kiegroup/kogito-examples' + + KOGITO_EXAMPLES_BUILD_MVN_OPTS = '-Dvalidate-formatting' + } + stages { + stage('Initialize') { + steps { + script { + // load `pr_check.groovy` file from kogito-pipelines:main + dir('kogito-pipelines') { + checkout(githubscm.resolveRepository('kogito-pipelines', 'kiegroup', 'apache_migration', false, 'kie-ci')) // TODO to change back to kiegroup:main + pr_check_script = load 'dsl/scripts/pr_check.groovy' + } + } + } + } + stage('PR check') { + steps { + script { + dir('kogito-pipelines') { + pr_check_script.launch() + } + } + } + } + } +} diff --git a/.ci/jenkins/Jenkinsfile.deploy b/.ci/jenkins/Jenkinsfile.deploy index f9280f2bee..b2810ad024 100644 --- a/.ci/jenkins/Jenkinsfile.deploy +++ b/.ci/jenkins/Jenkinsfile.deploy @@ -10,12 +10,10 @@ examplesHelper = null 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 { @@ -23,20 +21,11 @@ pipeline { timeout(time: 180, 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}") - // Keep here for visitibility - MAVEN_OPTS = '-Xms1024m -Xmx4g' - PR_BRANCH_HASH = "${util.generateHash(10)}" - MAVEN_DEPLOY_LOCAL_DIR = "${WORKSPACE}/maven_deploy_dir" + MAVEN_DEPLOY_LOCAL_DIR = "/tmp/maven_deploy_dir" } stages { @@ -132,7 +121,7 @@ pipeline { if (params.SKIP_TESTS) { mvnCmd.skipTests() // Conflict somehow with Python testing. If `skipTests={anyvalue}` is set, then exec plugin is not executed ... } - util.runWithPythonVirtualEnv(mvnCmd.getFullRunCommand('clean install'), 'swf') + mvnCmd.run('clean install') } } } @@ -347,7 +336,7 @@ void runMavenDeploy(boolean localDeployment = false) { mvnCmd.skipTests(true).run('clean deploy') - util.runWithPythonVirtualEnv(mvnCmd.skipTests(true).getFullRunCommand('clean deploy'), 'swf') + mvnCmd.skipTests(true).run('clean deploy') } void runMavenStage() { diff --git a/.ci/jenkins/Jenkinsfile.post-release b/.ci/jenkins/Jenkinsfile.post-release index 6438bb61f8..e183f4593a 100644 --- a/.ci/jenkins/Jenkinsfile.post-release +++ b/.ci/jenkins/Jenkinsfile.post-release @@ -3,12 +3,10 @@ import org.jenkinsci.plugins.workflow.libs.Library 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 { @@ -19,7 +17,6 @@ pipeline { environment { CI_EMAIL_TO = credentials("${JENKINS_EMAIL_CREDS_ID}") - GITHUB_CLI_VERSION = '0.11.1' } stages { @@ -34,10 +31,7 @@ pipeline { // Verify version is set and if on right release branch assert getProjectVersion() - assert getBuildBranch() == util.getReleaseBranchFromVersion(getProjectVersion()) - - installGithubCLI() } } } @@ -112,15 +106,6 @@ void checkoutTag(String repo, String tagName, String localBranchName = tagName) sh "git checkout tags/${tagName} -b ${localBranchName}" } -void installGithubCLI() { - sh """ - wget https://github.com/cli/cli/releases/download/v${env.GITHUB_CLI_VERSION}/gh_${env.GITHUB_CLI_VERSION}_linux_amd64.tar.gz - tar xzf gh_${env.GITHUB_CLI_VERSION}_linux_amd64.tar.gz - mv gh_${env.GITHUB_CLI_VERSION}_linux_amd64/bin/gh . - rm -r gh_${env.GITHUB_CLI_VERSION}_linux_amd64* - """ -} - void setDefaultBranch(String defaultBranch) { withCredentials([string(credentialsId: env.GITHUB_TOKEN_CREDS_ID, variable: 'GITHUB_TOKEN')]) { // gh command from https://github.com/cli/cli/issues/929#issuecomment-629253585 diff --git a/.ci/jenkins/Jenkinsfile.promote b/.ci/jenkins/Jenkinsfile.promote index adfd86fa28..6ce2d3a6b2 100644 --- a/.ci/jenkins/Jenkinsfile.promote +++ b/.ci/jenkins/Jenkinsfile.promote @@ -8,7 +8,10 @@ examplesHelper = null pipeline { agent { - label 'ubuntu' + docker { + image env.AGENT_DOCKER_BUILDER_IMAGE + args env.AGENT_DOCKER_BUILDER_ARGS + } } options { diff --git a/.ci/jenkins/Jenkinsfile.quarkus-3.rewrite.pr b/.ci/jenkins/Jenkinsfile.quarkus-3.rewrite.pr index 37bcb13024..d67a569bb5 100644 --- a/.ci/jenkins/Jenkinsfile.quarkus-3.rewrite.pr +++ b/.ci/jenkins/Jenkinsfile.quarkus-3.rewrite.pr @@ -8,11 +8,10 @@ changeTarget = env.ghprbTargetBranch ?: CHANGE_TARGET 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 { timestamps() @@ -56,7 +55,7 @@ pipeline { env.BUILD_MVN_OPTS = "${env.BUILD_MVN_OPTS ?: ''} -s ${MAVEN_SETTINGS_FILE} -Dmaven.wagon.http.ssl.insecure=true -Dmaven.test.failure.ignore=true" echo "BUILD_MVN_OPTS = ${BUILD_MVN_OPTS}" - util.runWithPythonVirtualEnv('.ci/environments/quarkus-3/before.sh rewrite', 'swf') + sh '.ci/environments/quarkus-3/before.sh rewrite' } } } diff --git a/.ci/jenkins/Jenkinsfile.quarkus-3.rewrite.standalone b/.ci/jenkins/Jenkinsfile.quarkus-3.rewrite.standalone index ab79db5a8c..0e7fbe79fb 100644 --- a/.ci/jenkins/Jenkinsfile.quarkus-3.rewrite.standalone +++ b/.ci/jenkins/Jenkinsfile.quarkus-3.rewrite.standalone @@ -7,12 +7,10 @@ previousHash = '' 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 { @@ -75,7 +73,7 @@ pipeline { env.BUILD_MVN_OPTS = "${env.BUILD_MVN_OPTS ?: ''} -s ${MAVEN_SETTINGS_FILE} -Dmaven.wagon.http.ssl.insecure=true -Dmaven.test.failure.ignore=true" echo "BUILD_MVN_OPTS = ${BUILD_MVN_OPTS}" - util.runWithPythonVirtualEnv('.ci/environments/quarkus-3/before.sh rewrite', 'swf') + sh '.ci/environments/quarkus-3/before.sh rewrite' } } } diff --git a/.ci/jenkins/Jenkinsfile.setup-branch b/.ci/jenkins/Jenkinsfile.setup-branch index 4ec458096d..3b3e2f7746 100644 --- a/.ci/jenkins/Jenkinsfile.setup-branch +++ b/.ci/jenkins/Jenkinsfile.setup-branch @@ -11,12 +11,10 @@ kogitoAppsRepo = 'kogito-apps' 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 { @@ -24,17 +22,8 @@ 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 - KOGITO_CI_EMAIL_TO = credentials("${JENKINS_EMAIL_CREDS_ID}") - - // Keep here for visitibility - MAVEN_OPTS = '-Xms1024m -Xmx4g' } stages { diff --git a/.ci/jenkins/dsl/jobs.groovy b/.ci/jenkins/dsl/jobs.groovy index 5825c1b4fe..3b3aef60be 100644 --- a/.ci/jenkins/dsl/jobs.groovy +++ b/.ci/jenkins/dsl/jobs.groovy @@ -121,7 +121,7 @@ void setupSpecificBuildChainNightlyJob(String envName, Closure defaultJobParamsG void createSetupBranchJob() { def jobParams = JobParamsUtils.getBasicJobParams(this, 'kogito-examples', JobType.SETUP_BRANCH, "${jenkins_path}/Jenkinsfile.setup-branch", 'Kogito Examples Init branch') - JobParamsUtils.setupJobParamsDefaultMavenConfiguration(this, jobParams) + JobParamsUtils.setupJobParamsAgentDockerBuilderImageConfiguration(this, jobParams) jobParams.env.putAll([ JENKINS_EMAIL_CREDS_ID: "${JENKINS_EMAIL_CREDS_ID}", @@ -148,7 +148,7 @@ void createSetupBranchJob() { void setupReleaseDeployJob() { def jobParams = JobParamsUtils.getBasicJobParams(this, 'kogito-examples-deploy', JobType.RELEASE, "${jenkins_path}/Jenkinsfile.deploy", 'Kogito Examples Deploy') - JobParamsUtils.setupJobParamsDefaultMavenConfiguration(this, jobParams) + JobParamsUtils.setupJobParamsAgentDockerBuilderImageConfiguration(this, jobParams) jobParams.env.putAll([ PROPERTIES_FILE_NAME: 'deployment.properties', @@ -190,7 +190,7 @@ void setupReleaseDeployJob() { void setupReleasePromoteJob() { def jobParams = JobParamsUtils.getBasicJobParams(this, 'kogito-examples-promote', JobType.RELEASE, "${jenkins_path}/Jenkinsfile.promote", 'Kogito Examples Promote') - JobParamsUtils.setupJobParamsDefaultMavenConfiguration(this, jobParams) + JobParamsUtils.setupJobParamsAgentDockerBuilderImageConfiguration(this, jobParams) jobParams.env.putAll([ PROPERTIES_FILE_NAME: 'deployment.properties', @@ -226,7 +226,7 @@ void setupReleasePromoteJob() { void setupPostReleaseJob() { def jobParams = JobParamsUtils.getBasicJobParams(this, 'kogito-examples-post-release', JobType.RELEASE, "${jenkins_path}/Jenkinsfile.post-release", 'Kogito Examples Post Release') - JobParamsUtils.setupJobParamsDefaultMavenConfiguration(this, jobParams) + JobParamsUtils.setupJobParamsAgentDockerBuilderImageConfiguration(this, jobParams) jobParams.env.putAll([ JENKINS_EMAIL_CREDS_ID: "${JENKINS_EMAIL_CREDS_ID}", @@ -250,7 +250,7 @@ void setupPostReleaseJob() { void setupPrQuarkus3RewriteJob() { def jobParams = JobParamsUtils.getBasicJobParamsWithEnv(this, 'kogito-examples.rewrite', JobType.PULL_REQUEST, 'quarkus-3', "${jenkins_path}/Jenkinsfile.quarkus-3.rewrite.pr", 'Kogito Examples Quarkus 3 rewrite patch regeneration') - JobParamsUtils.setupJobParamsDefaultMavenConfiguration(this, jobParams) + JobParamsUtils.setupJobParamsAgentDockerBuilderImageConfiguration(this, jobParams) jobParams.jenkinsfile = "${jenkins_path}/Jenkinsfile.quarkus-3.rewrite.pr" jobParams.pr.putAll([ run_only_for_branches: [ "${GIT_BRANCH}" ], @@ -270,7 +270,7 @@ void setupPrQuarkus3RewriteJob() { void setupStandaloneQuarkus3RewriteJob() { def jobParams = JobParamsUtils.getBasicJobParams(this, 'kogito-examples.quarkus-3.rewrite', JobType.TOOLS, "${jenkins_path}/Jenkinsfile.quarkus-3.rewrite.standalone", 'Kogito Examples Quarkus 3 rewrite patch regeneration') jobParams.env.putAll(EnvUtils.getEnvironmentEnvVars(this, 'quarkus-3')) - JobParamsUtils.setupJobParamsDefaultMavenConfiguration(this, jobParams) + JobParamsUtils.setupJobParamsAgentDockerBuilderImageConfiguration(this, jobParams) jobParams.env.putAll([ AUTHOR_CREDS_ID: "${GIT_AUTHOR_CREDENTIALS_ID}", JENKINS_EMAIL_CREDS_ID: "${JENKINS_EMAIL_CREDS_ID}",