This is an automated email from the ASF dual-hosted git repository.

ricardozanini pushed a commit to branch radtriste-fix-pipelines
in repository 
https://gitbox.apache.org/repos/asf/incubator-kie-kogito-images.git

commit 1f4ec14fc9b2757efe4c5db1b26493956acd3a21
Author: jstastny-cz <[email protected]>
AuthorDate: Wed Nov 8 13:27:07 2023 +0100

    refactor Jenkinsfile to a dummy trigger
---
 .ci/jenkins/Jenkinsfile                            | 77 +++-------------------
 .../{Jenkinsfile => Jenkinsfile.build-and-test}    | 21 ++++--
 .ci/jenkins/dsl/jobs.groovy                        | 54 +++++++++++++++
 3 files changed, 78 insertions(+), 74 deletions(-)

diff --git a/.ci/jenkins/Jenkinsfile b/.ci/jenkins/Jenkinsfile
index d80ffec6..86548427 100644
--- a/.ci/jenkins/Jenkinsfile
+++ b/.ci/jenkins/Jenkinsfile
@@ -6,94 +6,33 @@ pipeline {
     }
     options {
         timeout(time: 120, unit: 'MINUTES')
+        disableConcurrentBuilds(abortPrevious: true)
+        skipDefaultCheckout()
     }
     stages {
-        stage('Initialization') {
-            steps {
-                script {
-                    sh 'printenv'
-                    
-                    dir(getRepoName()) {
-                        // githubscm.checkoutIfExists(getRepoName(), 
getChangeAuthor(), getChangeBranch(), 'apache', getChangeTarget(), true, 
credentials = [token: getGitAuthorCredentialsId(), usernamePassword: 'kie-ci'])
-                        // TODO Test pupose
-                        deleteDir()
-                        
checkout(githubscm.resolveRepository('incubator-kie-kogito-images', 'apache', 
'radtriste-fix-pipelines', false))
-                    }
-                }
-            }
-        }
-        stage('Validate CeKit Image and Modules descriptors') {
-            steps {
-                script {
-                    dir(getRepoName()) {
-                        sh '''
-                            curl -Ls 
https://github.com/kiegroup/kie-cloud-tools/releases/download/v1.3.6/cekit-image-validator-runner.tgz
 --output cekit-image-validator-runner.tgz
-                            tar -xzvf cekit-image-validator-runner.tgz
-                            chmod +x cekit-image-validator-runner
-                        '''
-                        sh './cekit-image-validator-runner modules/'
-                        getImages().each { image -> sh 
"./cekit-image-validator-runner ${image}-image.yaml" }
-                    }
-                }
-            }
-        }
-        stage('Build & Test Images') {
-            steps {
-                script {
-                    dir(getRepoName()) {
-                        parallelStages = [:]
-                        for(String image : getImages()){
-                            parallelStages[image] = 
createBuildAndTestStageClosure(image)
-                        }
-                        parallel parallelStages
-                    }
-                }
-            }
-        }
-    }
-    post {
-        unsuccessful {
-            script {
-                pullrequest.postComment(util.getMarkdownTestSummary('PR', '', 
"${BUILD_URL}", 'GITHUB'))
-            }
-        }
-    }
-}
-
-Closure createBuildAndTestStageClosure(String image) {
-    return {
-        stage("Build&Test ${image}") {
+        stage("Build&Test") {
             List buildParams = []
             buildParams.add(string(name: "DISPLAY_NAME", value: "PR 
#${CHANGE_ID} - ${image}: ${CHANGE_URL}"))
-            buildParams.add(string(name: 'BUILD_IMAGE_NAME', value: image))
+            buildParams.add(string(name: "CHANGE_ID", value: CHANGE_ID))
+            buildParams.add(string(name: "CHANGE_URL", value: CHANGE_URL))
             buildParams.add(string(name: 'SOURCE_AUTHOR', value: 
getChangeAuthor()))
             buildParams.add(string(name: 'SOURCE_BRANCH', value: 
getChangeBranch()))
             buildParams.add(string(name: 'TARGET_BRANCH', value: 
getChangeTarget()))
             buildParams.add(string(name: 'BUILD_KOGITO_APPS_REF', value: 
getChangeTarget()))
             
-            
githubscm.prepareCommitStatusInformationForPullRequest(getRepoName(), 
getChangeAuthor(), getChangeBranch(), 'apache', getGitAuthorCredentialsId())
-            githubscm.updateGithubCommitStatus(image, 'PENDING', 'Queued', 
getRepoName())
-            
             // Keep executing so we can cancel all if needed
-            def job = build(job: "${getRepoName()}.build-image", wait: true, 
parameters: buildParams, propagate: false)
+            def job = build(job: "${getRepoName()}.build-and-test", wait: 
true, parameters: buildParams, propagate: false)
             if (job.result != 'SUCCESS') {
                 if (job.result == 'UNSTABLE') {
-                    unstable("Tests on ${image} seems to have failed")
+                    unstable("Tests on images seems to have failed: 
${job.absoluteUrl}")
                 } else {
-                    error("Error building ${image}. Please check the logs of 
the job: ${job.absoluteUrl}")
+                    error("Error building images. Please check the logs of the 
job: ${job.absoluteUrl}")
                 }
             }
         }
     }
 }
 
-String[] getImages() {
-    if (env.IMAGES_LIST) {
-        return env.IMAGES_LIST.split(',')
-    }
-    return sh(returnStdout: true, script: "make list | tr '\\n' 
','").trim().split(',')
-}
-
 String getChangeAuthor() {
     return CHANGE_AUTHOR
 }
diff --git a/.ci/jenkins/Jenkinsfile b/.ci/jenkins/Jenkinsfile.build-and-test
similarity index 92%
copy from .ci/jenkins/Jenkinsfile
copy to .ci/jenkins/Jenkinsfile.build-and-test
index d80ffec6..12eb8a76 100644
--- a/.ci/jenkins/Jenkinsfile
+++ b/.ci/jenkins/Jenkinsfile.build-and-test
@@ -2,7 +2,10 @@
 
 pipeline {
     agent {
-        label 'ubuntu'
+        docker { 
+            image env.AGENT_DOCKER_BUILDER_IMAGE
+            args env.AGENT_DOCKER_BUILDER_ARGS
+        }
     }
     options {
         timeout(time: 120, unit: 'MINUTES')
@@ -64,7 +67,7 @@ Closure createBuildAndTestStageClosure(String image) {
     return {
         stage("Build&Test ${image}") {
             List buildParams = []
-            buildParams.add(string(name: "DISPLAY_NAME", value: "PR 
#${CHANGE_ID} - ${image}: ${CHANGE_URL}"))
+            buildParams.add(string(name: "DISPLAY_NAME", value: "PR 
#${getChangeId()} - ${image}: ${getChangeUrl()}"))
             buildParams.add(string(name: 'BUILD_IMAGE_NAME', value: image))
             buildParams.add(string(name: 'SOURCE_AUTHOR', value: 
getChangeAuthor()))
             buildParams.add(string(name: 'SOURCE_BRANCH', value: 
getChangeBranch()))
@@ -95,15 +98,23 @@ String[] getImages() {
 }
 
 String getChangeAuthor() {
-    return CHANGE_AUTHOR
+    return SOURCE_AUTHOR
 }
 
 String getChangeBranch() {
-    return CHANGE_BRANCH
+    return SOURCE_BRANCH
 }
 
 String getChangeTarget() {
-    return CHANGE_TARGET
+    return TARGET_BRANCH
+}
+
+String getChangeId() {
+    return CHANGE_ID
+}
+
+String getChangeUrl() {
+    return CHANGE_URL
 }
 
 String getRepoName() {
diff --git a/.ci/jenkins/dsl/jobs.groovy b/.ci/jenkins/dsl/jobs.groovy
index 7655e5bc..cf649084 100644
--- a/.ci/jenkins/dsl/jobs.groovy
+++ b/.ci/jenkins/dsl/jobs.groovy
@@ -39,6 +39,7 @@ setupQuarkusUpdateJob()
 
 void setupPrJob() {
     setupBuildImageJob(JobType.PULL_REQUEST)
+    setupBuildAndTestJob(JobType.PULL_REQUEST)
 
     // Branch Source Plugin multibranchPipelineJob
     Utils.isMainBranch(this) && 
KogitoJobTemplate.createPullRequestMultibranchPipelineJob(this, 
"${jenkins_path}/Jenkinsfile", JobType.PULL_REQUEST.getName())
@@ -181,6 +182,59 @@ void setupBuildImageJob(JobType jobType) {
     }
 }
 
+void setupBuildAndTestJob(JobType jobType) {
+    def jobParams = JobParamsUtils.getBasicJobParams(this, 
'kogito-images.build-and-test', jobType, 
"${jenkins_path}/Jenkinsfile.build-and-test", 'Kogito Images Build And test 
images')
+    // Use jenkinsfile from the build branch
+    jobParams.git.author = '${SOURCE_AUTHOR}'
+    jobParams.git.branch = '${SOURCE_BRANCH}'
+    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
+
+        AUTHOR_CREDS_ID: "${GIT_AUTHOR_CREDENTIALS_ID}",
+        AUTHOR_TOKEN_CREDS_ID: "${GIT_AUTHOR_TOKEN_CREDENTIALS_ID}",
+    ])
+    if (Utils.hasBindingValue(this, 'CLOUD_IMAGES')) {
+        jobParams.env.put('IMAGES_LIST', Utils.getBindingValue(this, 
'CLOUD_IMAGES'))
+    }
+    KogitoJobTemplate.createPipelineJob(this, jobParams)?.with {
+        logRotator {
+            daysToKeep(10)
+        }
+        parameters {
+            stringParam('DISPLAY_NAME', '', 'Setup a specific build display 
name')
+
+            stringParam('SOURCE_AUTHOR', Utils.getGitAuthor(this), 'Build 
author')
+            stringParam('SOURCE_BRANCH', Utils.getGitBranch(this), 'Build 
branch name')
+            stringParam('TARGET_BRANCH', '', '(Optional) In case of a PR to 
merge with target branch, please provide the target branch')
+            stringParam('CHANGE_ID', '', 'CHANGE_ID coming from Branch Source 
Plugin')
+            stringParam('CHANGE_URL', '', 'CHANGE_URL coming from Branch 
Source Plugin')
+
+            // Build information
+            stringParam('MAVEN_ARTIFACTS_REPOSITORY', 
"${MAVEN_ARTIFACTS_REPOSITORY}")
+            stringParam('BUILD_KOGITO_APPS_URI', '', '(Optional) Git uri to 
the kogito-apps repository to use for tests.')
+            stringParam('BUILD_KOGITO_APPS_REF', '', '(Optional) Git reference 
(branch/tag) to the kogito-apps repository to use for building. Default to 
BUILD_BRANCH_NAME.')
+            stringParam('QUARKUS_PLATFORM_URL', 
Utils.getMavenQuarkusPlatformRepositoryUrl(this), 'URL to the Quarkus platform 
to use. The version to use will be guessed from artifacts.')
+
+            // Test information
+            booleanParam('SKIP_TESTS', false, 'Skip tests')
+            stringParam('TESTS_KOGITO_EXAMPLES_URI', '', '(Optional) Git uri 
to the kogito-examples repository to use for tests.')
+            stringParam('TESTS_KOGITO_EXAMPLES_REF', '', '(Optional) Git 
reference (branch/tag) to the kogito-examples repository to use for tests.')
+
+            // Deploy information
+            booleanParam('DEPLOY_IMAGE', false, 'Should we deploy image to 
given deploy registry ?')
+            booleanParam('DEPLOY_IMAGE_USE_OPENSHIFT_REGISTRY', false, 'Set to 
true if image should be deployed in Openshift registry.In this case, 
IMAGE_REGISTRY_CREDENTIALS, IMAGE_REGISTRY and IMAGE_NAMESPACE parameters will 
be ignored')
+            stringParam('DEPLOY_IMAGE_REGISTRY_CREDENTIALS', 
"${CLOUD_IMAGE_REGISTRY_CREDENTIALS}", 'Image registry credentials to use to 
deploy images. Will be ignored if no IMAGE_REGISTRY is given')
+            stringParam('DEPLOY_IMAGE_REGISTRY', "${CLOUD_IMAGE_REGISTRY}", 
'Image registry to use to deploy images')
+            stringParam('DEPLOY_IMAGE_NAMESPACE', "${CLOUD_IMAGE_NAMESPACE}", 
'Image namespace to use to deploy images')
+            stringParam('DEPLOY_IMAGE_NAME_SUFFIX', '', 'Image name suffix to 
use to deploy images. In case you need to change the final image name, you can 
add a suffix to it.')
+            stringParam('DEPLOY_IMAGE_TAG', '', 'Image tag to use to deploy 
images')
+            booleanParam('DEPLOY_WITH_LATEST_TAG', false, 'Set to true if you 
want the deployed images to also be with the `latest` tag')
+        }
+    }
+}
+
 void setupPromoteJob(JobType jobType) {
     def jobParams = JobParamsUtils.getBasicJobParams(this, 
'kogito-images-promote', jobType, "${jenkins_path}/Jenkinsfile.promote", 
'Kogito Images Promote')
     JobParamsUtils.setupJobParamsAgentDockerBuilderImageConfiguration(this, 
jobParams)


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to