diff --git a/.ci/jenkins/Jenkinsfile.deploy b/.ci/jenkins/Jenkinsfile.deploy index b0537bccc59..5fae3667d39 100644 --- a/.ci/jenkins/Jenkinsfile.deploy +++ b/.ci/jenkins/Jenkinsfile.deploy @@ -21,7 +21,6 @@ import org.jenkinsci.plugins.workflow.libs.Library @Library('jenkins-pipeline-shared-libraries')_ import org.kie.jenkins.MavenCommand -import org.kie.jenkins.MavenStagingHelper deployProperties = [:] @@ -43,7 +42,6 @@ pipeline { DROOLS_CI_EMAIL_TO = credentials("${JENKINS_EMAIL_CREDS_ID}") PR_BRANCH_HASH = "${util.generateHash(10)}" - MAVEN_DEPLOY_LOCAL_DIR = "/tmp/maven_deploy_dir" } stages { @@ -113,17 +111,25 @@ pipeline { } } } - stage('Build & Test') { + stage('Deploy drools') { steps { script { - configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){ - getMavenCommand() - .withOptions(env.DROOLS_BUILD_MVN_OPTS ? [ env.DROOLS_BUILD_MVN_OPTS ] : []) - .withOptions(env.BUILD_MVN_OPTS_CURRENT ? [ env.BUILD_MVN_OPTS_CURRENT ] : []) - .withProperty('maven.test.failure.ignore', true) - .skipTests(params.SKIP_TESTS) - .withSettingsXmlFile(MAVEN_SETTINGS_FILE) - .run('clean install') + withCredentials([usernamePassword(credentialsId: env.MAVEN_REPO_CREDS_ID, usernameVariable: 'REPOSITORY_USER', passwordVariable: 'REPOSITORY_TOKEN')]) { + def installOrDeploy + if (shouldDeployToRepository()) { + installOrDeploy = "deploy -DdeployAtEnd -Dapache.repository.username=${REPOSITORY_USER} -Dapache.repository.password=${REPOSITORY_TOKEN} -DretryFailedDeploymentCount=5" + } else { + installOrDeploy = 'install' + } + configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){ + getMavenCommand() + .withOptions(env.DROOLS_BUILD_MVN_OPTS ? [ env.DROOLS_BUILD_MVN_OPTS ] : []) + .withOptions(env.BUILD_MVN_OPTS_CURRENT ? [ env.BUILD_MVN_OPTS_CURRENT ] : []) + .withProperty('maven.test.failure.ignore', true) + .skipTests(params.SKIP_TESTS) + .withSettingsXmlFile(MAVEN_SETTINGS_FILE) + .run("clean $installOrDeploy") + } } } } @@ -136,24 +142,6 @@ pipeline { } } } - stage('Deploy locally') { - steps { - script { - runMavenDeploy(true) - } - } - } - stage('Stage artifacts') { - when { - expression { return shouldStageArtifacts() } - } - steps { - script { - // Stage release artifacts - runMavenStage() - } - } - } stage('Create PR') { when { expression { return isRelease() || isCreatePr() } @@ -231,10 +219,6 @@ void sendNotification() { } } -boolean shouldStageArtifacts() { - return isRelease() -} - boolean shouldDeployToRepository() { return env.MAVEN_DEPLOY_REPOSITORY || getGitAuthor() == 'apache' } @@ -295,42 +279,6 @@ MavenCommand getMavenCommand(String directory = '') { return mvnCmd } -void runMavenDeploy(boolean localDeployment = false) { - mvnCmd = getMavenCommand() - - if(localDeployment) { - mvnCmd.withLocalDeployFolder(getLocalDeploymentFolder()) - } else if (env.MAVEN_DEPLOY_REPOSITORY) { - mvnCmd.withDeployRepository(env.MAVEN_DEPLOY_REPOSITORY) - } - - configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){ - mvnCmd.skipTests(true) - .withOptions(env.DROOLS_BUILD_MVN_OPTS ? [ env.DROOLS_BUILD_MVN_OPTS ] : []) - .withOptions(env.BUILD_MVN_OPTS_CURRENT ? [ env.BUILD_MVN_OPTS_CURRENT ] : []) - .withSettingsXmlFile(MAVEN_SETTINGS_FILE) - .run('clean deploy') - } -} - -void runMavenStage() { - 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(MavenCommand mavenCommand) { - return new MavenStagingHelper(this, mavenCommand) - .withNexusReleaseUrl(env.NEXUS_RELEASE_URL) - .withNexusReleaseRepositoryId(env.NEXUS_RELEASE_REPOSITORY_ID) -} - -String getLocalDeploymentFolder() { - return "${env.MAVEN_DEPLOY_LOCAL_DIR}/${getRepoName()}" -} - boolean isMainStream() { return env.DROOLS_STREAM == 'main' } \ No newline at end of file diff --git a/.ci/jenkins/Jenkinsfile.weekly.deploy b/.ci/jenkins/Jenkinsfile.weekly.deploy index dc8b1b8447c..72cea4e9661 100644 --- a/.ci/jenkins/Jenkinsfile.weekly.deploy +++ b/.ci/jenkins/Jenkinsfile.weekly.deploy @@ -85,38 +85,24 @@ pipeline { } } - stage('Build & Test & Deploy locally') { - steps { - script { - runMavenLocalDeploy(params.SKIP_TESTS) - } - } - post { - always { - script { - saveReports() - util.archiveConsoleLog() - } - } - } - } - - stage('Upload artifacts to given repository') { - when { - expression { return shouldDeployToRepository() } - } + stage('Build & Test & Install/Deploy') { steps { script { withCredentials([usernamePassword(credentialsId: env.MAVEN_REPO_CREDS_ID, usernameVariable: 'REPOSITORY_USER', passwordVariable: 'REPOSITORY_TOKEN')]) { - configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]) { + def installOrDeploy + if (shouldDeployToRepository()) { + installOrDeploy = "deploy -DdeployAtEnd -Dapache.repository.username=${REPOSITORY_USER} -Dapache.repository.password=${REPOSITORY_TOKEN} -DretryFailedDeploymentCount=5" + } else { + installOrDeploy = 'install' + } + configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){ getMavenCommand() + .withOptions(env.DROOLS_BUILD_MVN_OPTS ? [ env.DROOLS_BUILD_MVN_OPTS ] : []) + .withOptions(env.BUILD_MVN_OPTS_CURRENT ? [ env.BUILD_MVN_OPTS_CURRENT ] : []) + .withProperty('maven.test.failure.ignore', true) + .skipTests(params.SKIP_TESTS) .withSettingsXmlFile(MAVEN_SETTINGS_FILE) - .withProperty('wagon.source', "file://${getLocalDeploymentFolder()}") - .withProperty('wagon.target', env.MAVEN_DEPLOY_REPOSITORY) - .withProperty('wagon.targetId', 'apache-snapshots-repository') - .withProperty('apache.snapshot.repository.username', REPOSITORY_USER) - .withProperty('apache.snapshot.repository.password', REPOSITORY_TOKEN) - .run("org.codehaus.mojo:wagon-maven-plugin:2.0.2:merge-maven-repos") + .run("clean $installOrDeploy") } } } @@ -226,24 +212,6 @@ MavenCommand getMavenCommand(String directory = '') { return mvnCmd } -void runMavenLocalDeploy(boolean skipTests = true) { - mvnCmd = getMavenCommand() - mvnCmd.withLocalDeployFolder(getLocalDeploymentFolder()) - - configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){ - mvnCmd.withProperty('maven.test.failure.ignore', true) - .withOptions(env.DROOLS_BUILD_MVN_OPTS ? [ env.DROOLS_BUILD_MVN_OPTS ] : []) - .withOptions(env.BUILD_MVN_OPTS_CURRENT ? [ env.BUILD_MVN_OPTS_CURRENT ] : []) - .skipTests(skipTests) - .withSettingsXmlFile(MAVEN_SETTINGS_FILE) - .run('clean deploy') - } -} - -String getLocalDeploymentFolder() { - return "${env.MAVEN_DEPLOY_LOCAL_DIR}/${getRepoName()}" -} - boolean isMainStream() { return env.DROOLS_STREAM == 'main' } diff --git a/.ci/jenkins/dsl/jobs.groovy b/.ci/jenkins/dsl/jobs.groovy index 60608acc0af..9de7fa8698f 100644 --- a/.ci/jenkins/dsl/jobs.groovy +++ b/.ci/jenkins/dsl/jobs.groovy @@ -323,14 +323,6 @@ void setupDeployJob(JobType jobType) { DROOLS_STREAM: Utils.getStream(this), ]) - if (jobType == JobType.RELEASE) { - jobParams.env.putAll([ - NEXUS_RELEASE_URL: "${MAVEN_NEXUS_RELEASE_URL}", - NEXUS_RELEASE_REPOSITORY_ID: "${MAVEN_NEXUS_RELEASE_REPOSITORY}", - NEXUS_STAGING_PROFILE_ID: "${MAVEN_NEXUS_STAGING_PROFILE_ID}", - NEXUS_BUILD_PROMOTION_PROFILE_ID: "${MAVEN_NEXUS_BUILD_PROMOTION_PROFILE_ID}", - ]) - } KogitoJobTemplate.createPipelineJob(this, jobParams)?.with { parameters { stringParam('DISPLAY_NAME', '', 'Setup a specific build display name')