Skip to content

Commit

Permalink
kie-issues#667: fix cleanup and settingsXml handling (#3272)
Browse files Browse the repository at this point in the history
* kie-issues#667: fix cleanup and settingsXml handling

* adjust also MavenCommands passed to maven library methods

---------

Co-authored-by: jstastny-cz <[email protected]>
  • Loading branch information
jstastny-cz and jstastny-cz authored Nov 2, 2023
1 parent 965c335 commit 0338971
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 40 deletions.
54 changes: 40 additions & 14 deletions .ci/jenkins/Jenkinsfile.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pipeline {
stage('Initialize') {
steps {
script {
cleanWs()
cleanWs(disableDeferredWipeout: true)

if (params.DISPLAY_NAME) {
currentBuild.displayName = params.DISPLAY_NAME
Expand Down Expand Up @@ -91,12 +91,28 @@ pipeline {
}
steps {
script {
maven.mvnVersionsSet(getMavenCommand(), getProjectVersion(), !isRelease())
maven.mvnSetVersionProperty(getMavenCommand(), 'version.org.kie', getDroolsVersion())
configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){
maven.mvnVersionsSet(
getMavenCommand().withSettingsXmlFile(MAVEN_SETTINGS_FILE),
getProjectVersion(),
!isRelease()
)
maven.mvnSetVersionProperty(
getMavenCommand().withSettingsXmlFile(MAVEN_SETTINGS_FILE),
'version.org.kie', getDroolsVersion()
)

// Need artifacts available locally
getMavenCommand().withProperty('quickly').run('clean install')
maven.mvnSetVersionProperty(getMavenCommand(getWorkflowCommonDeploymentPath()), 'data-index-ephemeral.image', getDataIndexEphemeralReleaseImage())
getMavenCommand()
.withProperty('quickly')
.withSettingsXmlFile(MAVEN_SETTINGS_FILE)
.run('clean install')
maven.mvnSetVersionProperty(
getMavenCommand(getWorkflowCommonDeploymentPath()).withSettingsXmlFile(MAVEN_SETTINGS_FILE),
'data-index-ephemeral.image',
getDataIndexEphemeralReleaseImage()
)
}
}
}
}
Expand All @@ -112,7 +128,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')
}
}
}
}
Expand Down Expand Up @@ -196,7 +216,7 @@ pipeline {
}
cleanup {
script {
util.cleanNode('docker')
util.cleanNode()
}
}
}
Expand Down Expand Up @@ -286,7 +306,6 @@ void setDeployPropertyIfNeeded(String key, def value) {
MavenCommand getMavenCommand(String directory = '') {
directory = directory ?: getRepoName()
return new MavenCommand(this, ['-fae', '-ntp'])
.withSettingsXmlId(env.MAVEN_SETTINGS_CONFIG_FILE_ID)
.withOptions(env.BUILD_MVN_OPTS ? [ env.BUILD_MVN_OPTS ] : [])
.inDirectory(directory)
.withProperty('full')
Expand All @@ -303,21 +322,28 @@ void runMavenDeploy(boolean localDeployment = false) {
mvnCmd.withDeployRepository(env.MAVEN_DEPLOY_REPOSITORY)
}

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')
}
}

String getMavenRepoZipUrl() {
return "${env.MAVEN_DEPLOY_REPOSITORY.replaceAll('/content/', '/service/local/').replaceFirst('/*$', '')}/content-compressed"
}

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)
}
Expand Down
4 changes: 2 additions & 2 deletions .ci/jenkins/Jenkinsfile.promote
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pipeline {
stage('Initialization') {
steps {
script {
cleanWs()
cleanWs(disableDeferredWipeout: true)

if (params.DISPLAY_NAME != '') {
currentBuild.displayName = params.DISPLAY_NAME
Expand Down Expand Up @@ -73,7 +73,7 @@ pipeline {
}
cleanup {
script {
util.cleanNode('docker')
util.cleanNode()
}
}
}
Expand Down
16 changes: 9 additions & 7 deletions .ci/jenkins/Jenkinsfile.quarkus-3.rewrite.pr
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pipeline {
stage('Initialization') {
steps {
script {
cleanWs()
cleanWs(disableDeferredWipeout: true)

sh 'printenv > env_props'
archiveArtifacts artifacts: 'env_props'
Expand All @@ -40,7 +40,12 @@ pipeline {
dir('drools') {
githubscm.checkoutIfExists('incubator-kie-drools', 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')
}
}
}
}
Expand Down Expand Up @@ -70,10 +75,8 @@ pipeline {
}
}
post {
always {
script {
cleanWs()
}
cleanup {
cleanWs()
}
unsuccessful {
script {
Expand All @@ -93,6 +96,5 @@ 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 ] : [])
}
10 changes: 7 additions & 3 deletions .ci/jenkins/Jenkinsfile.quarkus-3.rewrite.standalone
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ pipeline {
dir('drools') {
githubscm.checkoutIfExists('incubator-kie-drools', 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')
}
}
}
}
Expand Down Expand Up @@ -117,7 +122,7 @@ pipeline {

void clean() {
sh 'rm -rf ~/.rewrite-cache/'
util.cleanNode('docker')
util.cleanNode()
}

void sendErrorNotification() {
Expand Down Expand Up @@ -171,6 +176,5 @@ 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 ] : [])
}
51 changes: 37 additions & 14 deletions .ci/jenkins/Jenkinsfile.setup-branch
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pipeline {
stage('Initialize') {
steps {
script {
cleanWs()
cleanWs(disableDeferredWipeout: true)

if (params.DISPLAY_NAME) {
currentBuild.displayName = params.DISPLAY_NAME
Expand All @@ -41,23 +41,47 @@ pipeline {
stage('Build Drools') {
steps {
script {
getMavenCommand(droolsRepo)
.withProperty('quickly')
.withOptions(env.BUILD_MVN_OPTS_UPSTREAM ? [ env.BUILD_MVN_OPTS_UPSTREAM ] : [])
.withOptions(env.DROOLS_BUILD_MVN_OPTS_UPSTREAM ? [ env.DROOLS_BUILD_MVN_OPTS_UPSTREAM ] : [])
.run('clean install')
configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){
getMavenCommand(droolsRepo)
.withProperty('quickly')
.withOptions(env.BUILD_MVN_OPTS_UPSTREAM ? [ env.BUILD_MVN_OPTS_UPSTREAM ] : [])
.withOptions(env.DROOLS_BUILD_MVN_OPTS_UPSTREAM ? [ env.DROOLS_BUILD_MVN_OPTS_UPSTREAM ] : [])
.withSettingsXmlFile(MAVEN_SETTINGS_FILE)
.run('clean install')
}
}
}
}
stage('Update project version') {
steps {
script {
maven.mvnVersionsSet(getMavenCommand(getRepoName()).withProperty('full'), getKogitoVersion(), true)
maven.mvnSetVersionProperty(getMavenCommand(getRepoName()), 'version.org.kie', getDroolsVersion())

// Need artifacts available locally
getMavenCommand(getRepoName()).withProperty('quickly').run('clean install')
maven.mvnSetVersionProperty(getMavenCommand(getRepoName()).withOptions(['-pl :kogito-quarkus-workflow-common-deployment']), 'data-index-ephemeral.image', getDataIndexEphemeralImage())
configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){
maven.mvnVersionsSet(
getMavenCommand(getRepoName())
.withProperty('full')
.withSettingsXmlFile(MAVEN_SETTINGS_FILE),
getKogitoVersion(),
true
)
maven.mvnSetVersionProperty(
getMavenCommand(getRepoName()).withSettingsXmlFile(MAVEN_SETTINGS_FILE),
'version.org.kie',
getDroolsVersion()
)

// Need artifacts available locally
getMavenCommand(getRepoName())
.withProperty('quickly')
.withSettingsXmlFile(MAVEN_SETTINGS_FILE)
.run('clean install')
maven.mvnSetVersionProperty(
getMavenCommand(getRepoName())
.withOptions(['-pl :kogito-quarkus-workflow-common-deployment'])
.withSettingsXmlFile(MAVEN_SETTINGS_FILE),
'data-index-ephemeral.image',
getDataIndexEphemeralImage()
)
}
}
}
}
Expand All @@ -84,7 +108,7 @@ pipeline {
}
cleanup {
script {
util.cleanNode('docker')
util.cleanNode()
}
}
}
Expand Down Expand Up @@ -146,7 +170,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)
}
Expand Down

0 comments on commit 0338971

Please sign in to comment.