Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kie-issues#667: fix cleanup and settingsXml handling #1909

Merged
merged 2 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/jenkins/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
38 changes: 24 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 @@ -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()
)
}
}
}
}
Expand Down Expand Up @@ -176,7 +182,7 @@ pipeline {
}
cleanup {
script {
util.cleanNode('docker')
util.cleanNode()
}
}
}
Expand Down Expand Up @@ -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')
}
Expand All @@ -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)
}
Expand Down
56 changes: 29 additions & 27 deletions .ci/jenkins/Jenkinsfile.optaplanner
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
}
}
}
Expand All @@ -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 {
Expand All @@ -94,11 +106,6 @@ pipeline {
util.archiveConsoleLog()
}
}
cleanup {
script {
cleanContainers()
}
}
}
}
}
Expand All @@ -108,7 +115,7 @@ pipeline {
}
cleanup {
script {
util.cleanNode('docker')
util.cleanNode()
}
}
}
Expand Down Expand Up @@ -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
}
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 @@ -72,7 +72,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 @@ -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')
}
}
}
}
Expand Down Expand Up @@ -72,10 +77,8 @@ pipeline {
}
}
post {
always {
script {
cleanWs()
}
cleanup {
cleanWs()
}
unsuccessful {
script {
Expand All @@ -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')
}
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 @@ -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')
}
}
}
}
Expand Down Expand Up @@ -120,7 +125,7 @@ pipeline {

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

void sendErrorNotification() {
Expand Down Expand Up @@ -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')
}
39 changes: 25 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 @@ -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
)
}
}
}
}
Expand All @@ -91,7 +103,7 @@ pipeline {
}
cleanup {
script {
util.cleanNode('docker')
util.cleanNode()
}
}
}
Expand Down Expand Up @@ -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)
}