From c0584e71936e3a1720bbe0d7693b873cabc74b1f Mon Sep 17 00:00:00 2001 From: radtriste Date: Thu, 3 Aug 2023 16:14:32 +0200 Subject: [PATCH] KOGITO-9676 CI: Promote call setup-branch job --- .ci/jenkins/Jenkinsfile.promote | 116 +++----------------------------- 1 file changed, 11 insertions(+), 105 deletions(-) diff --git a/.ci/jenkins/Jenkinsfile.promote b/.ci/jenkins/Jenkinsfile.promote index 4b58c8b6da..631f887626 100644 --- a/.ci/jenkins/Jenkinsfile.promote +++ b/.ci/jenkins/Jenkinsfile.promote @@ -11,27 +11,14 @@ pipeline { label 'kie-rhel8 && docker && !built-in' } - tools { - maven env.BUILD_MAVEN_TOOL - jdk env.BUILD_JDK_TOOL - } - options { timestamps() - timeout(time: 180, unit: 'MINUTES') + timeout(time: 60, unit: 'MINUTES') } - // parameters { - // For parameters, check into ./dsl/jobs.groovy file - // } - environment { - // Static env is defined into ./dsl/jobs.groovy file - KOGITO_CI_EMAIL_TO = credentials("${JENKINS_EMAIL_CREDS_ID}") - PR_BRANCH_HASH = "${util.generateHash(10)}" - NODE_OPTIONS = '--max_old_space_size=4096' } @@ -47,59 +34,34 @@ pipeline { readDeployProperties() - if (isRelease()) { - // Verify version is set and if on right release branch - assert getProjectVersion() - - assert getBuildBranch() == util.getReleaseBranchFromVersion(getProjectVersion()) - } - - setupCypressEnv('9.7.0') + assert getProjectVersion() + assert getBuildBranch() == util.getReleaseBranchFromVersion(getProjectVersion()) } } } + stage('Merge deploy PR and tag') { - when { - expression { return isRelease() } - } steps { script { dir(getRepoName()) { checkoutRepo() mergeAndPush(getDeployPrLink()) tagLatest() - if(githubscm.isReleaseExist(getGitTag(), getGitAuthorCredsID())) { - githubscm.deleteRelease(getGitTag(), getGitAuthorCredsID()) - } - githubscm.createReleaseWithGeneratedReleaseNotes(getGitTag(), getBuildBranch(), githubscm.getPreviousTag(getGitTag()), getGitAuthorCredsID()) - githubscm.updateReleaseBody(getGitTag(), getGitAuthorCredsID()) } } } } - stage('Set apps next snapshot version') { - when { - expression { return isRelease() } - } + + stage('Create release') { steps { script { - dir('pr') { - checkoutRepo() - githubscm.createBranch(getSnapshotBranch()) - - maven.mvnVersionsUpdateParentAndChildModules(getMavenCommand(), getSnapshotVersion(), true) - - commitAndCreatePR() - } dir(getRepoName()) { - sh "git checkout ${getBuildBranch()}" - mergeAndPush(getPipelinePrLink()) - - if (shouldDeployToRepository()) { - runMavenDeploy() - } else { - echo 'Testing environment and no specific deploy repository given => no deployment' + checkoutRepo() + if (githubscm.isReleaseExist(getGitTag(), getGitAuthorCredsID())) { + githubscm.deleteRelease(getGitTag(), getGitAuthorCredsID()) } + githubscm.createReleaseWithGeneratedReleaseNotes(getGitTag(), getBuildBranch(), githubscm.getPreviousTag(getGitTag()), getGitAuthorCredsID()) + githubscm.updateReleaseBody(getGitTag(), getGitAuthorCredsID()) } } } @@ -125,12 +87,6 @@ void sendNotification() { } } -void setupCypressEnv(String cypressVersion) { - if (env.CYPRESS_BINARY_URL) { - env.CYPRESS_INSTALL_BINARY = "${CYPRESS_BINARY_URL}/cypress-${cypressVersion}.zip" - } -} - ////////////////////////////////////////////////////////////////////////////// // Deployment properties ////////////////////////////////////////////////////////////////////////////// @@ -170,14 +126,6 @@ String getParamOrDeployProperty(String paramKey, String deployPropertyKey) { // Getter / Setter ////////////////////////////////////////////////////////////////////////////// -boolean shouldDeployToRepository() { - return env.MAVEN_DEPLOY_REPOSITORY || getGitAuthor() == 'kiegroup' -} - -boolean isRelease() { - return env.RELEASE ? env.RELEASE.toBoolean() : false -} - String getRepoName() { return env.REPO_NAME } @@ -186,10 +134,6 @@ String getProjectVersion() { return getParamOrDeployProperty('PROJECT_VERSION', 'project.version') } -String getSnapshotVersion() { - return util.getNextVersion(getProjectVersion(), 'micro') -} - String getGitTag() { return params.GIT_TAG != '' ? params.GIT_TAG : getProjectVersion() } @@ -210,18 +154,6 @@ String getDeployPrLink() { return getDeployProperty("${getRepoName()}.pr.link") } -String getPipelinePrLink() { - return pipelineProperties["${getRepoName()}.pr.link"] -} - -void setPipelinePrLink(String value) { - pipelineProperties["${getRepoName()}.pr.link"] = value -} - -String getSnapshotBranch() { - return "${getSnapshotVersion().toLowerCase()}-${env.PR_BRANCH_HASH}" -} - ////////////////////////////////////////////////////////////////////////////// // Git ////////////////////////////////////////////////////////////////////////////// @@ -245,29 +177,3 @@ void tagLatest() { githubscm.tagLocalAndRemoteRepository('origin', getGitTag(), getGitAuthorCredsID(), env.BUILD_TAG, true) } } - -void commitAndCreatePR() { - def commitMsg = "[${getBuildBranch()}] Update version to ${getSnapshotVersion()}" - def prBody = "Generated by build ${BUILD_TAG}: ${BUILD_URL}.\nPlease do not merge, it should be merged automatically after testing." - - githubscm.commitChanges(commitMsg, { githubscm.findAndStageNotIgnoredFiles('pom.xml') }) - githubscm.pushObject('origin', getSnapshotBranch(), getGitAuthorCredsID()) - setPipelinePrLink(githubscm.createPR(commitMsg, prBody, getBuildBranch(), getGitAuthorCredsID())) -} - -MavenCommand getMavenCommand() { - mvnCmd = new MavenCommand(this, ['-fae', '-ntp']) - .withSettingsXmlId(env.MAVEN_SETTINGS_CONFIG_FILE_ID) - if (env.MAVEN_DEPENDENCIES_REPOSITORY) { - mvnCmd.withDependencyRepositoryInSettings('deps-repo', env.MAVEN_DEPENDENCIES_REPOSITORY) - } - return mvnCmd -} - -void runMavenDeploy() { - mvnCmd = getMavenCommand() - if (env.MAVEN_DEPLOY_REPOSITORY) { - mvnCmd.withDeployRepository(env.MAVEN_DEPLOY_REPOSITORY) - } - mvnCmd.skipTests(true).run('clean deploy') -}