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

tzimanyi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-kogito-apps.git


The following commit(s) were added to refs/heads/main by this push:
     new 2bc65a98d kie-issues#667: fix cleanup and settingsXml handling (#1909)
2bc65a98d is described below

commit 2bc65a98d011cec7ff5fbc34b8dba1686069d1f6
Author: Jan Stastny <[email protected]>
AuthorDate: Thu Nov 2 15:24:23 2023 +0100

    kie-issues#667: fix cleanup and settingsXml handling (#1909)
    
    * kie-issues#667: fix cleanup and settingsXml handling
    
    * adjust also MavenCommands passed to maven library methods
    
    ---------
    
    Co-authored-by: jstastny-cz <[email protected]>
---
 .ci/jenkins/Jenkinsfile                            |  2 +-
 .ci/jenkins/Jenkinsfile.deploy                     | 38 +++++++++------
 .ci/jenkins/Jenkinsfile.optaplanner                | 56 +++++++++++-----------
 .ci/jenkins/Jenkinsfile.promote                    |  4 +-
 .ci/jenkins/Jenkinsfile.quarkus-3.rewrite.pr       | 16 ++++---
 .../Jenkinsfile.quarkus-3.rewrite.standalone       | 10 ++--
 .ci/jenkins/Jenkinsfile.setup-branch               | 39 +++++++++------
 7 files changed, 97 insertions(+), 68 deletions(-)

diff --git a/.ci/jenkins/Jenkinsfile b/.ci/jenkins/Jenkinsfile
index 13b81b96f..2defd4155 100644
--- a/.ci/jenkins/Jenkinsfile
+++ b/.ci/jenkins/Jenkinsfile
@@ -21,7 +21,7 @@ pipeline {
     stages {
         stage('Initialize') {
             steps {
-                cleanWs()
+                cleanWs(disableDeferredWipeout: true)
                 script {
                     // load `pr_check.groovy` file from kogito-pipelines:main
                     dir('kogito-pipelines') {
diff --git a/.ci/jenkins/Jenkinsfile.deploy b/.ci/jenkins/Jenkinsfile.deploy
index b93aa49cc..5ca168f4d 100644
--- a/.ci/jenkins/Jenkinsfile.deploy
+++ b/.ci/jenkins/Jenkinsfile.deploy
@@ -36,7 +36,7 @@ pipeline {
         stage('Initialize') {
             steps {
                 script {
-                    cleanWs()
+                    cleanWs(disableDeferredWipeout: true)
 
                     if (params.DISPLAY_NAME) {
                         currentBuild.displayName = params.DISPLAY_NAME
@@ -90,7 +90,13 @@ pipeline {
             steps {
                 script {
                     dir(getRepoName()) {
-                        
maven.mvnVersionsUpdateParentAndChildModules(getMavenCommand(), 
getProjectVersion(), !isRelease())
+                        configFileProvider([configFile(fileId: 
env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){
+                            maven.mvnVersionsUpdateParentAndChildModules(
+                                
getMavenCommand().withSettingsXmlFile(MAVEN_SETTINGS_FILE),
+                                getProjectVersion(),
+                                !isRelease()
+                            )
+                        }
                     }
                 }
             }
@@ -176,7 +182,7 @@ pipeline {
         }
         cleanup {
             script {
-                util.cleanNode('docker')
+                util.cleanNode()
             }
         }
     }
@@ -269,7 +275,6 @@ void setDeployPropertyIfNeeded(String key, def value) {
 
 MavenCommand getMavenCommand() {
     return new MavenCommand(this, ['-fae', '-ntp'])
-            .withSettingsXmlId(env.MAVEN_SETTINGS_CONFIG_FILE_ID)
             .withOptions(env.BUILD_MVN_OPTS ? [ env.BUILD_MVN_OPTS ] : [])
             .withProperty('full')
 }
@@ -283,21 +288,26 @@ void runMavenDeploy(boolean skipTests = true, boolean 
localDeployment = false) {
         mvnCmd.withDeployRepository(env.MAVEN_DEPLOY_REPOSITORY)
     }
 
-    mvnCmd.withProperty('maven.test.failure.ignore', true)
-        .withOptions(env.BUILD_MVN_OPTS_CURRENT ? [ env.BUILD_MVN_OPTS_CURRENT 
] : [])
-        .withOptions(env.KOGITO_APPS_BUILD_MVN_OPTS ? [ 
env.KOGITO_APPS_BUILD_MVN_OPTS ] : [])
-        .skipTests(skipTests)
-        .run('clean deploy')
+    configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, 
variable: 'MAVEN_SETTINGS_FILE')]){
+        mvnCmd.withProperty('maven.test.failure.ignore', true)
+            .withOptions(env.BUILD_MVN_OPTS_CURRENT ? [ 
env.BUILD_MVN_OPTS_CURRENT ] : [])
+            .withOptions(env.KOGITO_APPS_BUILD_MVN_OPTS ? [ 
env.KOGITO_APPS_BUILD_MVN_OPTS ] : [])
+            .skipTests(skipTests)
+            .withSettingsXmlFile(MAVEN_SETTINGS_FILE)
+            .run('clean deploy')
+    }
 }
 
 void runMavenStage() {
-    MavenStagingHelper stagingHelper = getStagingHelper()
-    
deployProperties.putAll(stagingHelper.stageLocalArtifacts(env.NEXUS_STAGING_PROFILE_ID,
 getLocalDeploymentFolder()))
-    
stagingHelper.promoteStagingRepository(env.NEXUS_BUILD_PROMOTION_PROFILE_ID)
+    configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, 
variable: 'MAVEN_SETTINGS_FILE')]){
+        MavenStagingHelper stagingHelper = 
getStagingHelper(getMavenCommand().withSettingsXmlFile(MAVEN_SETTINGS_FILE))
+        
deployProperties.putAll(stagingHelper.stageLocalArtifacts(env.NEXUS_STAGING_PROFILE_ID,
 getLocalDeploymentFolder()))
+        
stagingHelper.promoteStagingRepository(env.NEXUS_BUILD_PROMOTION_PROFILE_ID)
+    }
 }
 
-MavenStagingHelper getStagingHelper() {
-    return new MavenStagingHelper(this, getMavenCommand())
+MavenStagingHelper getStagingHelper(MavenCommand mavenCommand) {
+    return new MavenStagingHelper(this, mavenCommand)
             .withNexusReleaseUrl(env.NEXUS_RELEASE_URL)
             .withNexusReleaseRepositoryId(env.NEXUS_RELEASE_REPOSITORY_ID)
 }
diff --git a/.ci/jenkins/Jenkinsfile.optaplanner 
b/.ci/jenkins/Jenkinsfile.optaplanner
index 5d365c30a..7c81c104f 100644
--- a/.ci/jenkins/Jenkinsfile.optaplanner
+++ b/.ci/jenkins/Jenkinsfile.optaplanner
@@ -35,18 +35,24 @@ pipeline {
         stage('Build Drools') {
             steps {
                 script {
-                    getMavenCommand(droolsRepo)
-                        .withProperty('quickly')
-                        .run('clean install')
+                    configFileProvider([configFile(fileId: 
env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){
+                        getMavenCommand(droolsRepo)
+                            .withProperty('quickly')
+                            .withSettingsXmlFile(MAVEN_SETTINGS_FILE)
+                            .run('clean install')
+                    }
                 }
             }
         }
         stage('Build Optaplanner') {
             steps {
                 script {
-                    getMavenCommand(optaplannerRepo)
-                        .withProperty('quickly')
-                        .run('clean install')
+                    configFileProvider([configFile(fileId: 
env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){
+                        getMavenCommand(optaplannerRepo)
+                            .withProperty('quickly')
+                            .withSettingsXmlFile(MAVEN_SETTINGS_FILE)
+                            .run('clean install')
+                    }
                 }
             }
         }
@@ -68,22 +74,28 @@ pipeline {
         stage('Build Runtimes') {
             steps {
                 script {
-                    getMavenCommand(kogitoRuntimesRepo)
-                        .withProperty('quickly')
-                        .run('clean install')
+                    configFileProvider([configFile(fileId: 
env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){
+                        getMavenCommand(kogitoRuntimesRepo)
+                            .withProperty('quickly')
+                            .withSettingsXmlFile(MAVEN_SETTINGS_FILE)
+                            .run('clean install')
+                        }
                 }
             }
         }
         stage('Build Apps') {
             steps {
                 script {
-                    getMavenCommand(kogitoAppsRepo)
-                        .withOptions(env.BUILD_MVN_OPTS_CURRENT ? [ 
env.BUILD_MVN_OPTS_CURRENT ] : [])
-                        .withProperty('skipUI')
-                        .withProperty('maven.test.failure.ignore', true)
-                        .withProperty('version.org.optaplanner', 
env.OPTAPLANNER_VERSION)
-                        .withProperty('optaplanner') // Use specific profile 
https://github.com/apache/incubator-kie-kogito-apps/blob/48a5c8f9a905a2c17b9d0e01cee744902a4824f0/pom.xml#L63
-                        .run('clean install')
+                    configFileProvider([configFile(fileId: 
env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){
+                        getMavenCommand(kogitoAppsRepo)
+                            .withOptions(env.BUILD_MVN_OPTS_CURRENT ? [ 
env.BUILD_MVN_OPTS_CURRENT ] : [])
+                            .withProperty('skipUI')
+                            .withProperty('maven.test.failure.ignore', true)
+                            .withProperty('version.org.optaplanner', 
env.OPTAPLANNER_VERSION)
+                            .withProperty('optaplanner') // Use specific 
profile 
https://github.com/apache/incubator-kie-kogito-apps/blob/48a5c8f9a905a2c17b9d0e01cee744902a4824f0/pom.xml#L63
+                            .withSettingsXmlFile(MAVEN_SETTINGS_FILE)
+                            .run('clean install')
+                    }
                 }
             }
             post {
@@ -94,11 +106,6 @@ pipeline {
                         util.archiveConsoleLog()
                     }
                 }
-                cleanup {
-                    script {
-                        cleanContainers()
-                    }
-                }
             }
         }
     }
@@ -108,7 +115,7 @@ pipeline {
         }
         cleanup {
             script {
-                util.cleanNode('docker')
+                util.cleanNode()
             }
         }
     }
@@ -167,16 +174,11 @@ String getOptaPlannerBranch() {
 
 MavenCommand getMavenCommand(String directory) {
     return new MavenCommand(this, ['-fae', '-ntp'])
-                .withSettingsXmlId('kie-release-settings')
                 .withProperty('java.net.preferIPv4Stack', true)
                 .withOptions(env.BUILD_MVN_OPTS ? [ env.BUILD_MVN_OPTS ] : [])
                 .inDirectory(directory)
 }
 
-void cleanContainers() {
-    cloud.cleanContainersAndImages('docker')
-}
-
 String getNativeBuilderImage() {
     return env.NATIVE_BUILDER_IMAGE
 }
diff --git a/.ci/jenkins/Jenkinsfile.promote b/.ci/jenkins/Jenkinsfile.promote
index aee9f51c0..fdcc0f8ef 100644
--- a/.ci/jenkins/Jenkinsfile.promote
+++ b/.ci/jenkins/Jenkinsfile.promote
@@ -25,7 +25,7 @@ pipeline {
         stage('Initialization') {
             steps {
                 script {
-                    cleanWs()
+                    cleanWs(disableDeferredWipeout: true)
 
                     if (params.DISPLAY_NAME) {
                         currentBuild.displayName = params.DISPLAY_NAME
@@ -72,7 +72,7 @@ pipeline {
         }
         cleanup {
             script {
-                util.cleanNode('docker')
+                util.cleanNode()
             }
         }
     }
diff --git a/.ci/jenkins/Jenkinsfile.quarkus-3.rewrite.pr 
b/.ci/jenkins/Jenkinsfile.quarkus-3.rewrite.pr
index e379b3cc9..d1c3e0e49 100644
--- a/.ci/jenkins/Jenkinsfile.quarkus-3.rewrite.pr
+++ b/.ci/jenkins/Jenkinsfile.quarkus-3.rewrite.pr
@@ -21,7 +21,7 @@ pipeline {
         stage('Initialization') {
             steps {
                 script {
-                    cleanWs()
+                    cleanWs(disableDeferredWipeout: true)
 
                     sh 'printenv > env_props'
                     archiveArtifacts artifacts: 'env_props'
@@ -41,7 +41,12 @@ pipeline {
                         dir(project) {
                             githubscm.checkoutIfExists(project, changeAuthor, 
changeBranch, 'apache', changeTarget, true)
                             sh '.ci/environments/update.sh quarkus-3'
-                            
getMavenCommand().withProperty('quickly').run('clean install')
+                            configFileProvider([configFile(fileId: 
env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){
+                                getMavenCommand()
+                                    .withProperty('quickly')
+                                    .withSettingsXmlFile(MAVEN_SETTINGS_FILE)
+                                    .run('clean install')
+                            }
                         }
                     }
                 }
@@ -72,10 +77,8 @@ pipeline {
         }
     }
     post {
-        always {
-            script {
-                cleanWs()
-            }
+        cleanup {
+            cleanWs()
         }
         unsuccessful {
             script {
@@ -95,7 +98,6 @@ String getGitAuthorCredsId() {
 
 MavenCommand getMavenCommand() {
     return new MavenCommand(this, ['-fae', '-ntp'])
-                .withSettingsXmlId(env.MAVEN_SETTINGS_CONFIG_FILE_ID)
                 .withOptions(env.BUILD_MVN_OPTS ? [ env.BUILD_MVN_OPTS ] : [])
                 .withProperty('enforcer.skip')
 }
diff --git a/.ci/jenkins/Jenkinsfile.quarkus-3.rewrite.standalone 
b/.ci/jenkins/Jenkinsfile.quarkus-3.rewrite.standalone
index 37cea8767..5fd9f04ae 100644
--- a/.ci/jenkins/Jenkinsfile.quarkus-3.rewrite.standalone
+++ b/.ci/jenkins/Jenkinsfile.quarkus-3.rewrite.standalone
@@ -59,7 +59,12 @@ pipeline {
                         dir(project) {
                             githubscm.checkoutIfExists(project, 
getGitAuthor(), getBuildBranch(), getBaseAuthor(), getBaseBranch(), true)
                             sh '.ci/environments/update.sh quarkus-3'
-                            
getMavenCommand().withProperty('quickly').run('clean install')
+                            configFileProvider([configFile(fileId: 
env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){
+                                getMavenCommand()
+                                    .withProperty('quickly')
+                                    .withSettingsXmlFile(MAVEN_SETTINGS_FILE)
+                                    .run('clean install')
+                            }
                         }
                     }
                 }
@@ -120,7 +125,7 @@ pipeline {
 
 void clean() {
     sh 'rm -rf ~/.rewrite-cache/'
-    util.cleanNode('docker')
+    util.cleanNode()
 }
 
 void sendErrorNotification() {
@@ -174,7 +179,6 @@ String getPRBranch() {
 
 MavenCommand getMavenCommand() {
     return new MavenCommand(this, ['-fae', '-ntp'])
-                .withSettingsXmlId(env.MAVEN_SETTINGS_CONFIG_FILE_ID)
                 .withOptions(env.BUILD_MVN_OPTS ? [ env.BUILD_MVN_OPTS ] : [])
                 .withProperty('enforcer.skip')
 }
diff --git a/.ci/jenkins/Jenkinsfile.setup-branch 
b/.ci/jenkins/Jenkinsfile.setup-branch
index b0d774401..21ffbcf18 100644
--- a/.ci/jenkins/Jenkinsfile.setup-branch
+++ b/.ci/jenkins/Jenkinsfile.setup-branch
@@ -27,7 +27,7 @@ pipeline {
         stage('Initialize') {
             steps {
                 script {
-                    cleanWs()
+                    cleanWs(disableDeferredWipeout: true)
 
                     if (params.DISPLAY_NAME) {
                         currentBuild.displayName = params.DISPLAY_NAME
@@ -42,29 +42,41 @@ pipeline {
         stage('Build Drools') {
             steps {
                 script {
-                    getMavenCommand(droolsRepo)
-                        .withOptions(env.BUILD_MVN_OPTS_UPSTREAM ? [ 
env.BUILD_MVN_OPTS_UPSTREAM ] : [])
-                        .withOptions(env.DROOLS_BUILD_MVN_OPTS_UPSTREAM ? [ 
env.DROOLS_BUILD_MVN_OPTS_UPSTREAM ] : [])
-                        .withProperty('quickly')
-                        .run('clean install')
+                    configFileProvider([configFile(fileId: 
env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){
+                        getMavenCommand(droolsRepo)
+                            .withOptions(env.BUILD_MVN_OPTS_UPSTREAM ? [ 
env.BUILD_MVN_OPTS_UPSTREAM ] : [])
+                            .withOptions(env.DROOLS_BUILD_MVN_OPTS_UPSTREAM ? 
[ env.DROOLS_BUILD_MVN_OPTS_UPSTREAM ] : [])
+                            .withProperty('quickly')
+                            .withSettingsXmlFile(MAVEN_SETTINGS_FILE)
+                            .run('clean install')
+                    }
                 }
             }
         }
         stage('Build Kogito Runtimes') {
             steps {
                 script {
-                    getMavenCommand(kogitoRuntimesRepo)
-                        .withOptions(env.BUILD_MVN_OPTS_UPSTREAM ? [ 
env.BUILD_MVN_OPTS_UPSTREAM ] : [])
-                        
.withOptions(env.KOGITO_RUNTIMES_BUILD_MVN_OPTS_UPSTREAM ? [ 
env.KOGITO_RUNTIMES_BUILD_MVN_OPTS_UPSTREAM ] : [])
-                        .withProperty('quickly')
-                        .run('clean install')
+                    configFileProvider([configFile(fileId: 
env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){
+                        getMavenCommand(kogitoRuntimesRepo)
+                            .withOptions(env.BUILD_MVN_OPTS_UPSTREAM ? [ 
env.BUILD_MVN_OPTS_UPSTREAM ] : [])
+                            
.withOptions(env.KOGITO_RUNTIMES_BUILD_MVN_OPTS_UPSTREAM ? [ 
env.KOGITO_RUNTIMES_BUILD_MVN_OPTS_UPSTREAM ] : [])
+                            .withProperty('quickly')
+                            .withSettingsXmlFile(MAVEN_SETTINGS_FILE)
+                            .run('clean install')
+                    }
                 }
             }
         }
         stage('Update project version') {
             steps {
                 script {
-                    
maven.mvnVersionsUpdateParentAndChildModules(getMavenCommand(getRepoName()), 
getKogitoVersion(), true)
+                    configFileProvider([configFile(fileId: 
env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){
+                        maven.mvnVersionsUpdateParentAndChildModules(
+                            
getMavenCommand(getRepoName()).withSettingsXmlFile(MAVEN_SETTINGS_FILE),
+                            getKogitoVersion(),
+                            true
+                        )
+                    }
                 }
             }
         }
@@ -91,7 +103,7 @@ pipeline {
         }
         cleanup {
             script {
-                util.cleanNode('docker')
+                util.cleanNode()
             }
         }
     }
@@ -149,7 +161,6 @@ String getGitAuthorCredsID() {
 
 MavenCommand getMavenCommand(String directory) {
     return new MavenCommand(this, ['-fae', '-ntp'])
-                .withSettingsXmlId(env.MAVEN_SETTINGS_CONFIG_FILE_ID)
                 .withOptions(env.BUILD_MVN_OPTS ? [ env.BUILD_MVN_OPTS ] : [])
                 .inDirectory(directory)
 }


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

Reply via email to