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

[10.0.x] kie-issues#1397: Adjust release pipelines for the Apache 10 release #6030

Merged
merged 2 commits into from
Jul 24, 2024
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
38 changes: 17 additions & 21 deletions .ci/jenkins/Jenkinsfile.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ deployProperties = [:]

pipeline {
agent {
docker {
docker {
image env.AGENT_DOCKER_BUILDER_IMAGE
args env.AGENT_DOCKER_BUILDER_ARGS
label util.avoidFaultyNodes()
Expand Down Expand Up @@ -87,7 +87,7 @@ pipeline {
steps {
script {
dir(getRepoName()) {
if (githubscm.isBranchExist('origin',getPRBranch())) {
if (githubscm.isBranchExist('origin', getPRBranch())) {
githubscm.removeRemoteBranch('origin', getPRBranch(), getGitAuthorPushCredsId())
}
githubscm.createBranch(getPRBranch())
Expand All @@ -101,7 +101,7 @@ pipeline {
}
steps {
script {
configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){
configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]) {
maven.mvnVersionsSet(
getMavenCommand().withSettingsXmlFile(MAVEN_SETTINGS_FILE),
getProjectVersion(),
Expand All @@ -127,18 +127,13 @@ pipeline {
.withProperty('maven.test.failure.ignore', true)
.skipTests(params.SKIP_TESTS)

def Closure mavenRunClosure = {
configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]) {
mavenCommand.withSettingsXmlFile(MAVEN_SETTINGS_FILE).run("clean $installOrDeploy")
}
}

if (isRelease()) {
release.gpgImportKeyFromStringWithoutPassword(getReleaseGpgSignKeyCredsId())
mavenCommand.withProfiles(['apache-release'])
mavenRunClosure()
} else {
mavenRunClosure()
}

configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]) {
mavenCommand.withSettingsXmlFile(MAVEN_SETTINGS_FILE).run("clean $installOrDeploy")
}
}
}
Expand All @@ -164,6 +159,11 @@ pipeline {
} else {
println '[WARN] no changes to commit'
}

// Create a new tag
githubscm.setUserConfigFromCreds(getGitAuthorPushCredsId())
githubscm.tagRepository(getGitTagName())
githubscm.pushRemoteTag('origin', getGitTagName(), getGitAuthorPushCredsId())
}
}
}
Expand Down Expand Up @@ -281,22 +281,18 @@ MavenCommand getMavenCommand(String directory = '') {
def mvnCmd = new MavenCommand(this, ['-fae', '-ntp'])
.withOptions(env.BUILD_MVN_OPTS ? [ env.BUILD_MVN_OPTS ] : [])
.inDirectory(directory)
if (!isMainStream()) { // Workaround as enforcer rules may not be fixed on other streams
mvnCmd.withProperty('enforcer.skip')
} else {
mvnCmd.withProperty('full')
}
.withProperty('full')
return mvnCmd
}

boolean isMainStream() {
return env.DROOLS_STREAM == 'main'
}

String getReleaseGpgSignKeyCredsId() {
return env.RELEASE_GPG_SIGN_KEY_CREDS_ID
}

String getReleaseGpgSignPassphraseCredsId() {
return env.RELEASE_GPG_SIGN_PASSPHRASE_CREDS_ID
}

String getGitTagName() {
return params.GIT_TAG_NAME
}
11 changes: 5 additions & 6 deletions .ci/jenkins/dsl/jobs.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,14 @@ void setupProjectReleaseJob() {

GIT_BRANCH_NAME: "${GIT_BRANCH}",
GIT_AUTHOR: "${GIT_AUTHOR_NAME}",

DEFAULT_STAGING_REPOSITORY: "${MAVEN_NEXUS_STAGING_PROFILE_URL}",
ARTIFACTS_REPOSITORY: "${MAVEN_ARTIFACTS_REPOSITORY}",

DROOLS_STREAM: Utils.getStream(this),
])
KogitoJobTemplate.createPipelineJob(this, jobParams)?.with {
parameters {
stringParam('RESTORE_FROM_PREVIOUS_JOB', '', 'URL to a previous stopped release job which needs to be continued')

stringParam('DROOLS_VERSION', '', 'Drools version to release as Major.minor.micro')
stringParam('RELEASE_VERSION', '', 'Drools version to release as Major.minor.micro')

stringParam('GIT_TAG_NAME', '', 'Git tag to create. i.e.: 10.0.0-rc1')

booleanParam('SKIP_TESTS', false, 'Skip all tests')
}
Expand Down Expand Up @@ -338,6 +335,8 @@ void setupDeployJob(JobType jobType) {
stringParam('PROJECT_VERSION', '', 'Optional if not RELEASE. If RELEASE, cannot be empty.')
stringParam('DROOLS_PR_BRANCH', '', 'PR branch name')

stringParam('GIT_TAG_NAME', '', 'Optional if not RELEASE. Tag to be created in the repository')

booleanParam('SEND_NOTIFICATION', false, 'In case you want the pipeline to send a notification on CI channel for this run.')
}
}
Expand Down
118 changes: 14 additions & 104 deletions .ci/jenkins/project/Jenkinsfile.release
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ import org.jenkinsci.plugins.workflow.libs.Library
@Library('jenkins-pipeline-shared-libraries')_

droolsRepo = 'drools'
// kieJpmmlIntegrationRepo = 'kie-jpmml-integration' // Commented as not migrated for now

ARTIFACTS_STAGING_STAGE = 'stage.artifacts.staging'
ARTIFACTS_RELEASE_STAGE = 'stage.artifacts.release'

JOB_PROPERTY_PREFIX = 'build'
JOB_RESULT_PROPERTY_KEY = 'result'
Expand Down Expand Up @@ -54,22 +52,17 @@ pipeline {
echo "Release properties imported from previous job: ${releaseProperties}"
}

assert getDroolsVersion()
assert getReleaseVersion()

currentBuild.displayName = getDisplayName()

sendNotification("Release Pipeline has started...\nDrools version = ${getDroolsVersion()}\n=> ${env.BUILD_URL}")

// Safety measure to not publish to main JBoss
if (getGitAuthor() != 'apache' && !getArtifactsRepositoryParam()) {
sendNotification("Git Author is different from `apache` and no `ARTIFACTS_REPOSITORY` parameter has been provided. Are you sure you want to continue ? => ${env.BUILD_URL}input")
input message: 'Should the pipeline continue with no `ARTIFACTS_REPOSITORY` defined ?', ok: 'Yes'
}
sendNotification("Release Pipeline has started...\nDrools version = ${getReleaseVersion()}\n=> ${env.BUILD_URL}")
}
}
post {
always {
setReleasePropertyIfneeded('drools.version', getDroolsVersion())
setReleasePropertyIfneeded('release.version', getReleaseVersion())
setReleasePropertyIfneeded('git.tag.name', getGitTagName())
}
}
}
Expand All @@ -79,89 +72,21 @@ pipeline {
script {
def buildParams = getDefaultBuildParams()
addSkipTestsParam(buildParams)

buildJob(getDeployJobName(droolsRepo), buildParams)
}
}
}

// stage('Build & Deploy KIE jpmml integration') {
// steps {
// script {
// def buildParams = getDefaultBuildParams()
// addSkipTestsParam(buildParams)

// buildJob(getDeployJobName(kieJpmmlIntegrationRepo), buildParams)
// }
// }
// }

stage('Artifacts\' staging finalization') {
steps {
script {
if (!areArtifactsStaged()) {
sendNotification("All artifacts have been staged. You can find them here: ${getStagingRepository()}")
sendNotification('All artifacts have been staged.')
}
setArtifactsStaged()
}
}
}

stage('Are staged artifacts released?') {
when {
// Execute only if artifacts repository was not given, which means the staging repository has been created
expression { return !getArtifactsRepositoryParam() && !areArtifactsReleased() }
}
steps {
script {
String body = "${getDroolsVersion()} artifacts are ready for release.\n" +
"Please release the staging repositories and then confirm here: ${env.BUILD_URL}input"
sendNotification(body)
input message: 'Has the staging repository been released ?', ok: 'Yes'

sendNotification('Artifacts have been released. Finalizing now the release ...')
setArtifactsReleased()
}
}
}

stage('Promote Drools') {
when {
expression { return isJobConsideredOk(getDeployJobName(droolsRepo)) }
}
steps {
script {
def buildParams = getDefaultBuildParams()
addDeployBuildUrlParam(buildParams, getDeployJobName(droolsRepo))

buildJob(getPromoteJobName(droolsRepo), buildParams)
}
}
}

// stage('Promote KIE jpmml integration') {
// when {
// expression { return isJobConsideredOk(getDeployJobName(kieJpmmlIntegrationRepo)) }
// }
// steps {
// script {
// def buildParams = getDefaultBuildParams()
// addDeployBuildUrlParam(buildParams, getDeployJobName(kieJpmmlIntegrationRepo))

// buildJob(getPromoteJobName(kieJpmmlIntegrationRepo), buildParams)
// }
// }
// }

stage('Setup next snapshot version') {
steps {
script {
def buildParams = []
addStringParam(buildParams, 'DROOLS_VERSION', util.getNextVersion(getDroolsVersion(), 'micro'))
build(job: '../setup-branch/0-setup-branch', wait: false, parameters: buildParams, propagate: false)
}
}
}
}
post {
always {
Expand Down Expand Up @@ -232,10 +157,6 @@ String getDeployJobName(String repository) {
return "${repository}-deploy"
}

String getPromoteJobName(String repository) {
return "${repository}-promote"
}

String getJobPropertySuffix(String jobName) {
return "${JOB_PROPERTY_PREFIX}.${jobName}"
}
Expand Down Expand Up @@ -330,9 +251,10 @@ def readPropertiesFromUrl(String url, String propsFilename) {

List getDefaultBuildParams() {
List buildParams = []
addDisplayNameParam(buildParams, getDisplayName(getDroolsVersion()))
addStringParam(buildParams, 'PROJECT_VERSION', getDroolsVersion())
addStringParam(buildParams, 'DROOLS_PR_BRANCH', "drools-${getDroolsVersion()}")
addDisplayNameParam(buildParams, getDisplayName(getReleaseVersion()))
addStringParam(buildParams, 'PROJECT_VERSION', getReleaseVersion())
addStringParam(buildParams, 'DROOLS_PR_BRANCH', "drools-${getReleaseVersion()}")
addStringParam(buildParams, 'GIT_TAG_NAME', getGitTagName())
return buildParams
}

Expand Down Expand Up @@ -367,26 +289,18 @@ void addBooleanParam(List buildParams, String key, boolean value) {
}

String getDisplayName(version = '') {
version = version ?: getDroolsVersion()
version = version ?: getReleaseVersion()
return "Release ${version}"
}

String getDroolsVersion() {
return params.DROOLS_VERSION ?: getReleaseProperty('drools.version')
String getReleaseVersion() {
return params.RELEASE_VERSION ?: getReleaseProperty('release.version')
}

String getGitAuthor() {
return env.GIT_AUTHOR
}

String getArtifactsRepositoryParam() {
return env['ARTIFACTS_REPOSITORY'] ?: ''
}

String getStagingRepository() {
return getArtifactsRepositoryParam() ?: env.DEFAULT_STAGING_REPOSITORY
}

void setReleasePropertyIfneeded(String key, def value) {
if (value) {
releaseProperties[key] = value
Expand Down Expand Up @@ -415,10 +329,6 @@ void setArtifactsStaged() {
setReleasePropertyIfneeded(ARTIFACTS_STAGING_STAGE, true)
}

boolean areArtifactsReleased() {
return hasReleaseProperty(ARTIFACTS_RELEASE_STAGE)
}

void setArtifactsReleased() {
setReleasePropertyIfneeded(ARTIFACTS_RELEASE_STAGE, true)
String getGitTagName() {
return params.GIT_TAG_NAME ?: getReleaseProperty('git.tag.name')
}
Loading