diff --git a/.ci/jenkins/Jenkinsfile.promote b/.ci/jenkins/Jenkinsfile.promote index ed8078c23..ded4957e7 100644 --- a/.ci/jenkins/Jenkinsfile.promote +++ b/.ci/jenkins/Jenkinsfile.promote @@ -29,8 +29,6 @@ pipeline { OPENSHIFT_CREDS_KEY = 'OPENSHIFT_CREDS' PR_BRANCH_HASH = "${util.generateHash(10)}" - - GITHUB_REPO = "${REPO_NAME}" // for github-release cli } stages { @@ -45,11 +43,8 @@ pipeline { readDeployProperties() - if (isRelease()) { - // Verify version is set and if on right release branch - assert getProjectVersion() - assert getBuildBranch() == util.getReleaseBranchFromVersion(getProjectVersion()) - } + assert getProjectVersion() + assert getBuildBranch() == util.getReleaseBranchFromVersion(getProjectVersion()) // Login old registry if (isOldImageInOpenshiftRegistry()) { @@ -69,11 +64,11 @@ pipeline { checkoutRepo() } - installGitHubReleaseCLI() cloud.installSkopeo() } } } + stage('Promote images') { steps { script { @@ -83,10 +78,8 @@ pipeline { } } } + stage('Merge PR and tag') { - when { - expression { return isRelease() } - } steps { script { dir(getRepoName()) { @@ -96,47 +89,19 @@ pipeline { githubscm.mergePR(prLink, getGitAuthorCredsID()) githubscm.pushObject('origin', getBuildBranch(), getGitAuthorCredsID()) } - - if (getGitTag()) { - createRelease() - } } } } } - stage('Set next version') - { - when { - expression { return isRelease() } - } + + stage('Create release') { steps { script { - String prLink = '' - String nextVersion = getNextVersion() - dir('pr') { // Use different folder from `Update PR with released Maven artifacts` to avoid conflicts - // Prepare PR - checkoutRepo() - githubscm.createBranch(getSnapshotBranch()) - - // Update version to next snapshot - versionCmd = "python3 scripts/manage-kogito-version.py --bump-to ${nextVersion} --artifacts-version ${getKogitoArtifactsNextVersion()} --confirm" - if (getBuildBranch() != 'main') { - versionCmd += " --examples-ref ${getBuildBranch()}" - } - runPythonCommand(versionCmd) - - def commitMsg = "[${getBuildBranch()}] Update snapshot version to ${nextVersion}" - def prBody = "Generated by build ${BUILD_TAG}: ${BUILD_URL}" - githubscm.commitChanges(commitMsg) - githubscm.pushObject('origin', getSnapshotBranch(), getGitAuthorCredsID()) - prLink = githubscm.createPR(commitMsg, prBody, getBuildBranch(), getGitAuthorCredsID()) - } - dir(getRepoName()) { - if (prLink) { - githubscm.mergePR(prLink, getGitAuthorCredsID()) - githubscm.pushObject('origin', getBuildBranch(), getGitAuthorCredsID()) - } + if (githubscm.isReleaseExist(getGitTag(), getGitAuthorCredsID())) { + githubscm.deleteReleaseAndTag(getGitTag(), getGitAuthorCredsID()) } + githubscm.createReleaseWithGeneratedReleaseNotes(getGitTag(), getBuildBranch(), githubscm.getPreviousTag(getGitTag()), getGitAuthorCredsID()) + githubscm.updateReleaseBody(getGitTag(), getGitAuthorCredsID()) } } } @@ -169,10 +134,6 @@ String getNotificationSubject() { return "[${getBuildBranch()}] Kogito Images" } -void installGitHubReleaseCLI() { - sh 'go install github.com/github-release/github-release@latest' -} - void checkoutRepo() { deleteDir() checkout(githubscm.resolveRepository(getRepoName(), getGitAuthor(), getBuildBranch(), false)) @@ -217,14 +178,6 @@ void makeQuayNewImagesPublic() { } } -void createRelease() { - if(githubscm.isReleaseExist(getGitTag(), getGitAuthorCredsID())) { - githubscm.deleteReleaseAndTag(getGitTag(), getGitAuthorCredsID()) - } - githubscm.createReleaseWithGeneratedReleaseNotes(getGitTag(), getBuildBranch(), githubscm.getPreviousTag(getGitTag()), getGitAuthorCredsID()) - githubscm.updateReleaseBody(getGitTag(), getGitAuthorCredsID()) -} - String getOldImageFullTag(String imageName) { return "${getOldImageRegistry()}/${getOldImageNamespace()}/${getFinalImageName(imageName, getOldImageNameSuffix())}:${getOldImageTag()}" } @@ -269,6 +222,7 @@ void loginContainerRegistry(String registry, String credsId) { sh "${env.CONTAINER_ENGINE} login -u ${REGISTRY_USER} -p ${REGISTRY_PWD} ${env.CONTAINER_ENGINE_TLS_OPTIONS ?: ''} ${registry}" } } + void readDeployProperties() { String deployUrl = params.DEPLOY_BUILD_URL if (deployUrl != '') { @@ -300,10 +254,6 @@ String getParamOrDeployProperty(String paramKey, String deployPropertyKey) { // Utils //////////////////////////////////////////////////////////////////////// -boolean isRelease() { - return env.RELEASE ? env.RELEASE.toBoolean() : false -} - String getRepoName() { return env.REPO_NAME } @@ -325,10 +275,6 @@ String getBuildBranch() { return params.BUILD_BRANCH_NAME } -String getPRSourceBranch() { - return getDeployProperty("${getRepoName()}.pr.source.ref") -} - String getGitAuthor() { return env.GIT_AUTHOR } @@ -337,23 +283,6 @@ String getGitAuthorCredsID() { return env.AUTHOR_CREDS_ID } -String getMavenArtifactRepository() { - return env.MAVEN_ARTIFACT_REPOSITORY ?: '' -} - -String getNextVersion() { - return util.getNextVersion(getProjectVersion(), 'micro', 'snapshot') -} - -// To be later changed by artifacts version parameter -String getKogitoArtifactsNextVersion() { - return util.getNextVersion(getKogitoArtifactsVersion(), 'micro', 'SNAPSHOT') -} - -String getSnapshotBranch() { - return "${getNextVersion()}-${env.PR_BRANCH_HASH}" -} - boolean isQuayRegistry(String registry) { return registry == 'quay.io' }