From 3bff3e9f9dbca79d775056774e6734679cf1e410 Mon Sep 17 00:00:00 2001 From: jstastny-cz Date: Wed, 1 Nov 2023 12:34:13 +0100 Subject: [PATCH] kie-issues#667: fix cleanup and settingsXml handling --- .ci/jenkins/Jenkinsfile.deploy | 35 +++++++++------ .ci/jenkins/Jenkinsfile.post-release | 4 +- .ci/jenkins/Jenkinsfile.promote | 4 +- .ci/jenkins/Jenkinsfile.quarkus-3.rewrite.pr | 16 ++++--- .../Jenkinsfile.quarkus-3.rewrite.standalone | 10 +++-- .ci/jenkins/Jenkinsfile.setup-branch | 44 +++++++++++-------- 6 files changed, 68 insertions(+), 45 deletions(-) diff --git a/.ci/jenkins/Jenkinsfile.deploy b/.ci/jenkins/Jenkinsfile.deploy index 172a081721..68890a3ecd 100644 --- a/.ci/jenkins/Jenkinsfile.deploy +++ b/.ci/jenkins/Jenkinsfile.deploy @@ -32,7 +32,7 @@ pipeline { stage('Initialize') { steps { script { - cleanWs() + cleanWs(disableDeferredWipeout: true) checkout scm examplesHelper = load '.ci/jenkins/helper_scripts/examples.groovy' @@ -121,7 +121,11 @@ pipeline { if (params.SKIP_TESTS) { mvnCmd.skipTests() // Conflict somehow with Python testing. If `skipTests={anyvalue}` is set, then exec plugin is not executed ... } - mvnCmd.run('clean install') + configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){ + mvnCmd + .withSettingsXmlFile(MAVEN_SETTINGS_FILE) + .run('clean install') + } } } } @@ -200,7 +204,7 @@ pipeline { } cleanup { script { - util.cleanNode('docker') + util.cleanNode() } } } @@ -312,7 +316,6 @@ void setDeployPropertyIfNeeded(String key, def value) { MavenCommand getMavenCommand() { MavenCommand mvnCmd = new MavenCommand(this, ['-fae', '-ntp']) - .withSettingsXmlId(env.MAVEN_SETTINGS_CONFIG_FILE_ID) .withOptions(env.BUILD_MVN_OPTS ? [ env.BUILD_MVN_OPTS ] : []) .withProperty('full') if (env.MAVEN_DEPENDENCIES_REPOSITORY) { @@ -333,20 +336,26 @@ void runMavenDeploy(boolean localDeployment = false) { } mvnCmd.withOptions(examplesHelper.getDeployableArtifactIds().collect { "-pl :${it} "}) - - mvnCmd.skipTests(true).run('clean deploy') - - mvnCmd.skipTests(true).run('clean deploy') + configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){ + mvnCmd + .skipTests(true) + .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) + MavenCommand mavenCommand = getMavenCommand() + configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){ + mavenCommand.withSettingsXmlFile(MAVEN_SETTINGS_FILE) + MavenStagingHelper stagingHelper = getStagingHelper(mavenCommand) + 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(def mavenCommand) { + return new MavenStagingHelper(this, mavenCommand) .withNexusReleaseUrl(env.NEXUS_RELEASE_URL) .withNexusReleaseRepositoryId(env.NEXUS_RELEASE_REPOSITORY_ID) } diff --git a/.ci/jenkins/Jenkinsfile.post-release b/.ci/jenkins/Jenkinsfile.post-release index e183f4593a..a68d5c5f76 100644 --- a/.ci/jenkins/Jenkinsfile.post-release +++ b/.ci/jenkins/Jenkinsfile.post-release @@ -23,7 +23,7 @@ pipeline { stage('Initialization') { steps { script { - cleanWs() + cleanWs(disableDeferredWipeout: true) if (params.DISPLAY_NAME) { currentBuild.displayName = params.DISPLAY_NAME @@ -53,7 +53,7 @@ pipeline { } cleanup { script { - util.cleanNode('docker') + util.cleanNode() } } } diff --git a/.ci/jenkins/Jenkinsfile.promote b/.ci/jenkins/Jenkinsfile.promote index 6ce2d3a6b2..d233fa149a 100644 --- a/.ci/jenkins/Jenkinsfile.promote +++ b/.ci/jenkins/Jenkinsfile.promote @@ -27,7 +27,7 @@ pipeline { stage('Initialization') { steps { script { - cleanWs() + cleanWs(disableDeferredWipeout: true) checkout scm examplesHelper = load '.ci/jenkins/helper_scripts/examples.groovy' @@ -77,7 +77,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 d794139f26..c945249b86 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 81bfac2629..814def1e20 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 2675617d16..d4741e894f 100644 --- a/.ci/jenkins/Jenkinsfile.setup-branch +++ b/.ci/jenkins/Jenkinsfile.setup-branch @@ -30,7 +30,7 @@ pipeline { stage('Initialize') { steps { script { - cleanWs() + cleanWs(disableDeferredWipeout: true) checkout scm examplesHelper = load '.ci/jenkins/helper_scripts/examples.groovy' @@ -49,33 +49,42 @@ 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('Build Kogito Apps') { steps { script { - getMavenCommand(kogitoAppsRepo) - .withOptions(env.BUILD_MVN_OPTS_UPSTREAM ? [ env.BUILD_MVN_OPTS_UPSTREAM ] : []) - .withOptions(env.KOGITO_APPS_BUILD_MVN_OPTS_UPSTREAM ? [ env.KOGITO_APPS_BUILD_MVN_OPTS_UPSTREAM ] : []) - .withProperty('quickly') - .run('clean install') + configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){ + getMavenCommand(kogitoAppsRepo) + .withOptions(env.BUILD_MVN_OPTS_UPSTREAM ? [ env.BUILD_MVN_OPTS_UPSTREAM ] : []) + .withOptions(env.KOGITO_APPS_BUILD_MVN_OPTS_UPSTREAM ? [ env.KOGITO_APPS_BUILD_MVN_OPTS_UPSTREAM ] : []) + .withProperty('quickly') + .withSettingsXmlFile(MAVEN_SETTINGS_FILE) + .run('clean install') + } } } } @@ -138,7 +147,7 @@ pipeline { } cleanup { script { - util.cleanNode('docker') + util.cleanNode() } } } @@ -200,7 +209,6 @@ String getGitAuthorCredsID() { MavenCommand getMavenCommand(String directory = '') { def mvnCmd = new MavenCommand(this, ['-fae', '-ntp']) - .withSettingsXmlId(env.MAVEN_SETTINGS_CONFIG_FILE_ID) .withOptions(env.BUILD_MVN_OPTS ? [ env.BUILD_MVN_OPTS ] : []) if (directory) { mvnCmd.inDirectory(directory)