Skip to content

Commit 79c52dc

Browse files
authored
[10.0.x] kie-issues#1397: Adjust release pipelines for the Apache 10 release (#3111)
* Adjust release pipelines for the Apache 10 release * Adjust release pipelines for the Apache 10 release
1 parent 1e82ff6 commit 79c52dc

File tree

3 files changed

+59
-108
lines changed

3 files changed

+59
-108
lines changed

.ci/jenkins/Jenkinsfile.deploy

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ imageUtils = null
3535

3636
pipeline {
3737
agent {
38-
docker {
38+
docker {
3939
image env.AGENT_DOCKER_BUILDER_IMAGE
4040
args env.AGENT_DOCKER_BUILDER_ARGS
4141
label util.avoidFaultyNodes()
@@ -52,7 +52,6 @@ pipeline {
5252
OPTAPLANNER_CI_EMAIL_TO = credentials("${JENKINS_EMAIL_CREDS_ID}")
5353

5454
PR_BRANCH_HASH = "${util.generateHash(10)}"
55-
5655
}
5756

5857
stages {
@@ -103,7 +102,7 @@ pipeline {
103102

104103
stage('Prepare for PR') {
105104
when {
106-
expression { return isRelease() || isCreatePr() }
105+
expression { return isCreatePr() }
107106
}
108107
steps {
109108
script {
@@ -144,19 +143,15 @@ pipeline {
144143
.withProperty('maven.test.failure.ignore', true)
145144
.withProperty('operator.image.build')
146145
.skipTests(params.SKIP_TESTS)
147-
def Closure mavenRunClosure = {
148-
configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]) {
149-
mavenCommand.withSettingsXmlFile(MAVEN_SETTINGS_FILE).run("clean $installOrDeploy")
150-
}
151-
}
146+
152147
if (isRelease()) {
153148
release.gpgImportKeyFromStringWithoutPassword(getReleaseGpgSignKeyCredsId())
154149
mavenCommand.withProfiles(['apache-release'])
155-
mavenRunClosure()
156-
} else {
157-
mavenRunClosure()
158150
}
159151

152+
configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]) {
153+
mavenCommand.withSettingsXmlFile(MAVEN_SETTINGS_FILE).run("clean $installOrDeploy")
154+
}
160155
}
161156
if (isRelease()) {
162157
updateAntoraYaml(optaplannerFolder)
@@ -176,7 +171,7 @@ pipeline {
176171
stage('Build Quickstarts') {
177172
steps {
178173
script {
179-
configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){
174+
configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]) {
180175
getOptaplannerQuickstartsMavenCommand()
181176
.withProperty('maven.test.failure.ignore', true)
182177
.skipTests(params.SKIP_TESTS)
@@ -197,7 +192,7 @@ pipeline {
197192

198193
stage('Create PRs') {
199194
when {
200-
expression { return isRelease() || isCreatePr() }
195+
expression { return isCreatePr() }
201196
}
202197
steps {
203198
script {
@@ -217,6 +212,18 @@ pipeline {
217212
}
218213
}
219214

215+
stage('Commit and Create Tag') {
216+
when {
217+
expression { return isRelease() }
218+
}
219+
steps {
220+
script {
221+
commitAndCreateTag(optaplannerFolder, getBuildBranch())
222+
commitAndCreateTag(quickstartsFolder, getQuickStartsBranch())
223+
}
224+
}
225+
}
226+
220227
stage('Push a temporary operator image to a registry') {
221228
when {
222229
expression { return isRelease() }
@@ -255,7 +262,7 @@ pipeline {
255262
void sendErrorNotification() {
256263
if (params.SEND_NOTIFICATION) {
257264
String additionalInfo = "**[${getBuildBranch()}] Optaplanner - Deploy**"
258-
mailer.sendMarkdownTestSummaryNotification("CI failures", [env.OPTAPLANNER_CI_EMAIL_TO], additionalInfo)
265+
mailer.sendMarkdownTestSummaryNotification('CI failures', [env.OPTAPLANNER_CI_EMAIL_TO], additionalInfo)
259266
} else {
260267
echo 'No notification sent per configuration'
261268
}
@@ -335,6 +342,20 @@ void prepareForPR(String folder) {
335342
}
336343
}
337344

345+
void commitAndCreateTag(String folder, String buildBranch) {
346+
dir(folder) {
347+
def commitMsg = "[${buildBranch}] Update project version to ${getProjectVersion()}"
348+
githubscm.setUserConfigFromCreds(getGitAuthorPushCredsId())
349+
githubscm.commitChanges(commitMsg, {
350+
githubscm.findAndStageNotIgnoredFiles('pom.xml')
351+
githubscm.findAndStageNotIgnoredFiles('build.gradle')
352+
githubscm.findAndStageNotIgnoredFiles('antora.yml')
353+
})
354+
githubscm.tagRepository(getGitTagName())
355+
githubscm.pushRemoteTag('origin', getGitTagName(), getGitAuthorPushCredsId())
356+
}
357+
}
358+
338359
void commitAndCreatePR(String folder, String repo, String buildBranch) {
339360
dir(folder) {
340361
def commitMsg = "[${buildBranch}] Update project version to ${getProjectVersion()}"
@@ -385,7 +406,7 @@ MavenCommand getOptaplannerQuickstartsMavenCommand() {
385406
* Builds the parent modules and the BOM so that project depending on these artifacts can resolve.
386407
*/
387408
void mavenCleanInstallOptaPlannerParents() {
388-
configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){
409+
configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]) {
389410
getOptaplannerMavenCommand()
390411
.skipTests(true)
391412
.withOptions(['-U', '-pl org.optaplanner:optaplanner-build-parent,org.optaplanner:optaplanner-bom', '-am'])
@@ -403,7 +424,7 @@ void runMavenDeploy(MavenCommand mvnCmd, String localDeploymentId = '') {
403424
mvnCmd.withDeployRepository(env.MAVEN_DEPLOY_REPOSITORY)
404425
}
405426

406-
configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){
427+
configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]) {
407428
mvnCmd
408429
.withSettingsXmlFile(MAVEN_SETTINGS_FILE)
409430
.skipTests(true)
@@ -532,4 +553,8 @@ String getReleaseGpgSignKeyCredsId() {
532553

533554
String getReleaseGpgSignPassphraseCredsId() {
534555
return env.RELEASE_GPG_SIGN_PASSPHRASE_CREDS_ID
535-
}
556+
}
557+
558+
String getGitTagName() {
559+
return params.GIT_TAG_NAME
560+
}

.ci/jenkins/dsl/jobs.groovy

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,19 +149,14 @@ void setupProjectReleaseJob() {
149149

150150
GIT_BRANCH_NAME: "${GIT_BRANCH}",
151151
GIT_AUTHOR: "${GIT_AUTHOR_NAME}",
152-
153-
DEFAULT_STAGING_REPOSITORY: "${MAVEN_NEXUS_STAGING_PROFILE_URL}",
154-
ARTIFACTS_REPOSITORY: "${MAVEN_ARTIFACTS_REPOSITORY}",
155-
OPTAPLANNER_LATEST_STREAM: "${GIT_MAIN_BRANCH}"
156152
])
157153
KogitoJobTemplate.createPipelineJob(this, jobParams)?.with {
158154
parameters {
159155
stringParam('RESTORE_FROM_PREVIOUS_JOB', '', 'URL to a previous stopped release job which needs to be continued')
160156

161-
stringParam('OPTAPLANNER_VERSION', '', 'Project version of OptaPlanner and its examples to release as Major.minor.micro')
162-
stringParam('OPTAPLANNER_RELEASE_BRANCH', '', '(optional) Use to override the release branch name deduced from the OPTAPLANNER_VERSION')
157+
stringParam('RELEASE_VERSION', '', 'Project version of OptaPlanner and its examples to release as Major.minor.micro')
163158

164-
stringParam('DROOLS_VERSION', '', '(optional) Drools version to be set to the project before releasing the artifacts.')
159+
stringParam('GIT_TAG_NAME', '', 'Git tag to create. i.e.: 10.0.0-rc1')
165160

166161
booleanParam('SKIP_TESTS', false, 'Skip all tests')
167162
}
@@ -370,6 +365,8 @@ void setupDeployJob(JobType jobType, String envName = '') {
370365
stringParam('OPERATOR_IMAGE_REGISTRY_TOKEN_CREDENTIALS_ID', "${CLOUD_IMAGE_REGISTRY_TOKEN_CREDENTIALS_ID}", 'Image registry token credentials id.')
371366
stringParam('OPERATOR_IMAGE_NAMESPACE', "${CLOUD_IMAGE_NAMESPACE}", 'Operator image namespace to use to deploy image.')
372367
stringParam('OPERATOR_IMAGE_TAG', '', 'Image tag to use to deploy the operator image. OptaPlanner project version if not set.')
368+
369+
stringParam('GIT_TAG_NAME', '', 'Optional if not RELEASE. Tag to be created in the repository')
373370
}
374371
}
375372
}

.ci/jenkins/project/Jenkinsfile.release

Lines changed: 13 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ import org.jenkinsci.plugins.workflow.libs.Library
2222
@Library('jenkins-pipeline-shared-libraries')_
2323

2424
OPTAPLANNER_DEPLOY = 'optaplanner-deploy'
25-
OPTAPLANNER_PROMOTE = 'optaplanner-promote'
2625

2726
ARTIFACTS_STAGING_STAGE = 'stage.artifacts.staging'
28-
ARTIFACTS_RELEASE_STAGE = 'stage.artifacts.release'
2927

3028
JOB_PROPERTY_PREFIX = 'build'
3129
JOB_RESULT_PROPERTY_KEY = 'result'
@@ -54,24 +52,17 @@ pipeline {
5452
echo "Release properties imported from previous job: ${releaseProperties}"
5553
}
5654

57-
assert getOptaPlannerVersion()
55+
assert getReleaseVersion()
5856

5957
currentBuild.displayName = getDisplayName()
6058

61-
sendNotification("Release Pipeline has started...\nOptaplanner version = ${getOptaPlannerVersion()}\n=> ${env.BUILD_URL}")
62-
63-
// Safety measure to not publish to main JBoss
64-
if (getGitAuthor() != 'apache' && !getArtifactsRepositoryParam()) {
65-
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")
66-
input message: 'Should the pipeline continue with no `ARTIFACTS_REPOSITORY` defined ?', ok: 'Yes'
67-
}
59+
sendNotification("Release Pipeline has started...\nOptaplanner version = ${getReleaseVersion()}\n=> ${env.BUILD_URL}")
6860
}
6961
}
7062
post {
7163
always {
72-
setReleasePropertyIfneeded('optaplanner.version', getOptaPlannerVersion())
73-
setReleasePropertyIfneeded('optaplanner.branch', getOptaPlannerReleaseBranch())
74-
setReleasePropertyIfneeded('drools.version', getDroolsVersion())
64+
setReleasePropertyIfneeded('release.version', getReleaseVersion())
65+
setReleasePropertyIfneeded('git.tag.name', getGitTagName())
7566
}
7667
}
7768
}
@@ -82,7 +73,6 @@ pipeline {
8273
def buildParams = getDefaultBuildParams()
8374
addSkipTestsParam(buildParams)
8475
addSkipIntegrationTestsParam(buildParams)
85-
addStringParam(buildParams, 'QUICKSTARTS_BUILD_BRANCH_NAME', getOptaPlannerReleaseBranch())
8676
buildJob(OPTAPLANNER_DEPLOY, buildParams)
8777
}
8878
}
@@ -92,54 +82,12 @@ pipeline {
9282
steps {
9383
script {
9484
if (!areArtifactsStaged()) {
95-
sendNotification("All artifacts have been staged. You can find them here: ${getStagingRepository()}")
85+
sendNotification('All artifacts have been staged.')
9686
}
9787
setArtifactsStaged()
9888
}
9989
}
10090
}
101-
102-
stage('Are staged artifacts released?') {
103-
when {
104-
// Execute only if artifacts repository was not given, which means the staging repository has been created
105-
expression { return !getArtifactsRepositoryParam() && !areArtifactsReleased() }
106-
}
107-
steps {
108-
script {
109-
String body = "${getOptaPlannerVersion()} artifacts are ready for release.\n" +
110-
"Please release the staging repositories and then confirm here: ${env.BUILD_URL}input"
111-
sendNotification(body)
112-
input message: 'Has the staging repository been released ?', ok: 'Yes'
113-
114-
sendNotification('Artifacts have been released. Finalizing now the release ...')
115-
setArtifactsReleased()
116-
}
117-
}
118-
}
119-
120-
stage('Promote OptaPlanner') {
121-
when {
122-
expression { return isJobConsideredOk(OPTAPLANNER_DEPLOY) }
123-
}
124-
steps {
125-
script {
126-
def buildParams = getDefaultBuildParams()
127-
addDeployBuildUrlParam(buildParams, OPTAPLANNER_DEPLOY)
128-
129-
buildJob(OPTAPLANNER_PROMOTE, buildParams)
130-
}
131-
}
132-
}
133-
134-
stage('Setup next snapshot version') {
135-
steps {
136-
script {
137-
def buildParams = []
138-
addStringParam(buildParams, 'OPTAPLANNER_VERSION', util.getNextVersion(getOptaPlannerVersion(), 'micro'))
139-
build(job: '../setup-branch/0-setup-branch', wait: false, parameters: buildParams, propagate: false)
140-
}
141-
}
142-
}
14391
}
14492
post {
14593
always {
@@ -301,9 +249,10 @@ def readPropertiesFromUrl(String url, String propsFilename) {
301249

302250
List getDefaultBuildParams() {
303251
List buildParams = []
304-
addDisplayNameParam(buildParams, getDisplayName(getOptaPlannerVersion()))
305-
addStringParam(buildParams, 'PROJECT_VERSION', getOptaPlannerVersion())
306-
addStringParam(buildParams, 'DROOLS_VERSION', getDroolsVersion())
252+
addDisplayNameParam(buildParams, getDisplayName(getReleaseVersion()))
253+
addStringParam(buildParams, 'PROJECT_VERSION', getReleaseVersion())
254+
addStringParam(buildParams, 'DROOLS_VERSION', getReleaseVersion())
255+
addStringParam(buildParams, 'GIT_TAG_NAME', getGitTagName())
307256
return buildParams
308257
}
309258

@@ -350,30 +299,14 @@ String getDisplayName(version = '') {
350299
return "Release ${version}"
351300
}
352301

353-
String getOptaPlannerVersion() {
354-
return params.OPTAPLANNER_VERSION ?: getReleaseProperty('optaplanner.version')
355-
}
356-
357-
String getDroolsVersion() {
358-
return params.DROOLS_VERSION ?: getReleaseProperty('drools.version')
302+
String getReleaseVersion() {
303+
return params.RELEASE_VERSION ?: getReleaseProperty('release.version')
359304
}
360305

361306
String getGitAuthor() {
362307
return env.GIT_AUTHOR
363308
}
364309

365-
String getArtifactsRepositoryParam() {
366-
return env['ARTIFACTS_REPOSITORY'] ?: ''
367-
}
368-
369-
String getOptaPlannerReleaseBranch() {
370-
return params.OPTAPLANNER_RELEASE_BRANCH ?: (getReleaseProperty('optaplanner.branch') ?: util.getReleaseBranchFromVersion(getOptaPlannerVersion()))
371-
}
372-
373-
String getStagingRepository() {
374-
return getArtifactsRepositoryParam() ?: env.DEFAULT_STAGING_REPOSITORY
375-
}
376-
377310
void setReleasePropertyIfneeded(String key, def value) {
378311
if (value) {
379312
releaseProperties[key] = value
@@ -402,10 +335,6 @@ void setArtifactsStaged() {
402335
setReleasePropertyIfneeded(ARTIFACTS_STAGING_STAGE, true)
403336
}
404337

405-
boolean areArtifactsReleased() {
406-
return hasReleaseProperty(ARTIFACTS_RELEASE_STAGE)
407-
}
408-
409-
void setArtifactsReleased() {
410-
setReleasePropertyIfneeded(ARTIFACTS_RELEASE_STAGE, true)
338+
String getGitTagName() {
339+
return params.GIT_TAG_NAME ?: getReleaseProperty('git.tag.name')
411340
}

0 commit comments

Comments
 (0)