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

KOGITO-9676 CI: Promote call setup-branch job #5441

Merged
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
4 changes: 2 additions & 2 deletions .ci/jenkins/Jenkinsfile.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pipeline {
environment {
// Static env is defined into ./dsl/jobs.groovy file

KOGITO_CI_EMAIL_TO = credentials("${JENKINS_EMAIL_CREDS_ID}")
DROOLS_CI_EMAIL_TO = credentials("${JENKINS_EMAIL_CREDS_ID}")

// Keep here for visitibility
MAVEN_OPTS = '-Xms1024m -Xmx4g'
Expand Down Expand Up @@ -201,7 +201,7 @@ void commitAndCreatePR() {

void sendNotification() {
if (params.SEND_NOTIFICATION) {
mailer.sendMarkdownTestSummaryNotification('Deploy', "[${getBuildBranch()}] Drools", [env.KOGITO_CI_EMAIL_TO])
mailer.sendMarkdownTestSummaryNotification('Deploy', "[${getBuildBranch()}] Drools", [env.DROOLS_CI_EMAIL_TO])
} else {
echo 'No notification sent per configuration'
}
Expand Down
102 changes: 17 additions & 85 deletions .ci/jenkins/Jenkinsfile.promote
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,8 @@ pipeline {
timeout(time: 180, 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)}"
DROOLS_CI_EMAIL_TO = credentials("${JENKINS_EMAIL_CREDS_ID}")
}

stages {
Expand All @@ -45,18 +37,12 @@ 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())
}
}
}
stage('Merge deploy PR and tag') {
when {
expression { return isRelease() }
}
steps {
script {
dir(getRepoName()) {
Expand All @@ -68,42 +54,29 @@ pipeline {
}
}

stage('Upload drools binaries and documentation') {
when {
expression { return isRelease() && isStream8() }
}
stage('Create release') {
steps {
script {
getMavenCommand().inDirectory(getRepoName()).skipTests(true).withProperty('full').run('clean install')
uploadFileMgmt(getRepoName())
dir(getRepoName()) {
checkoutRepo()
if(githubscm.isReleaseExist(getGitTag(), getGitAuthorCredsID())) {
githubscm.deleteRelease(getGitTag(), getGitAuthorCredsID())
}
githubscm.createReleaseWithGeneratedReleaseNotes(getGitTag(), getBuildBranch(), githubscm.getPreviousTag(getGitTag()), getGitAuthorCredsID())
githubscm.updateReleaseBody(getGitTag(), getGitAuthorCredsID())
}
}
}
}

stage('Set next snapshot version') {
stage('Upload drools binaries and documentation') {
when {
expression { return isRelease() }
expression { return isStream8() }
}
steps {
script {
dir('pr') {
checkoutRepo()
githubscm.createBranch(getSnapshotBranch())

maven.mvnVersionsSet(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'
}
}
getMavenCommand().inDirectory(getRepoName()).skipTests(true).withProperty('full').run('clean install')
uploadFileMgmt(getRepoName())
}
}
}
Expand All @@ -122,7 +95,7 @@ pipeline {

void sendNotification() {
if (params.SEND_NOTIFICATION) {
mailer.sendMarkdownTestSummaryNotification('Promote', "[${getBuildBranch()}] Drools", [env.KOGITO_CI_EMAIL_TO])
mailer.sendMarkdownTestSummaryNotification('Promote', "[${getBuildBranch()}] Drools", [env.DROOLS_CI_EMAIL_TO])
} else {
echo 'No notification sent per configuration'
}
Expand Down Expand Up @@ -167,14 +140,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
}
Expand All @@ -183,10 +148,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()
}
Expand All @@ -207,18 +168,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
//////////////////////////////////////////////////////////////////////////////
Expand All @@ -243,15 +192,6 @@ void tagLatest() {
}
}

void commitAndCreatePR() {
def commitMsg = "[${getBuildBranch()}] Update project version to ${getSnapshotVersion()}"
def prBody = "Generated by build ${BUILD_TAG}: ${BUILD_URL}.\nPlease do not merge, it should be merged automatically."

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}")
Expand All @@ -261,14 +201,6 @@ MavenCommand getMavenCommand() {
return mvnCmd
}

void runMavenDeploy() {
mvnCmd = getMavenCommand()
if (env.MAVEN_DEPLOY_REPOSITORY) {
mvnCmd.withDeployRepository(env.MAVEN_DEPLOY_REPOSITORY)
}
mvnCmd.skipTests(true).withProperty('enforcer.skip').run('clean deploy')
}

void uploadFileMgmt(String directory) {
if (isNotTestingBuild()) {
echo "upload binaries and docs for ${directory}"
Expand Down
6 changes: 3 additions & 3 deletions .ci/jenkins/Jenkinsfile.quarkus-3.rewrite.standalone
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pipeline {
}

environment {
KOGITO_CI_EMAIL_TO = credentials("${JENKINS_EMAIL_CREDS_ID}")
DROOLS_CI_EMAIL_TO = credentials("${JENKINS_EMAIL_CREDS_ID}")

PR_BRANCH_HASH = "${util.generateHash(10)}"
}
Expand Down Expand Up @@ -113,13 +113,13 @@ void clean() {
}

void sendErrorNotification() {
mailer.sendMarkdownTestSummaryNotification('quarkus-3', "[${getBuildBranch()}] Drools", [env.KOGITO_CI_EMAIL_TO])
mailer.sendMarkdownTestSummaryNotification('quarkus-3', "[${getBuildBranch()}] Drools", [env.DROOLS_CI_EMAIL_TO])
}

void sendNotification(String body) {
emailext body: "${body}",
subject: "[${getBuildBranch()}] Drools - quarkus-3",
to: env.KOGITO_CI_EMAIL_TO
to: env.DROOLS_CI_EMAIL_TO
}

void checkoutRepo(String repository, String branch) {
Expand Down
4 changes: 2 additions & 2 deletions .ci/jenkins/Jenkinsfile.setup-branch
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pipeline {
environment {
// Static env is defined into ./dsl/jobs.groovy file

KOGITO_CI_EMAIL_TO = credentials("${JENKINS_EMAIL_CREDS_ID}")
DROOLS_CI_EMAIL_TO = credentials("${JENKINS_EMAIL_CREDS_ID}")

// Keep here for visitibility
MAVEN_OPTS = '-Xms1024m -Xmx4g'
Expand Down Expand Up @@ -101,7 +101,7 @@ pipeline {

void sendNotification() {
if (params.SEND_NOTIFICATION) {
mailer.sendMarkdownTestSummaryNotification('Setup branch', "[${getBuildBranch()}] Drools", [env.KOGITO_CI_EMAIL_TO])
mailer.sendMarkdownTestSummaryNotification('Setup branch', "[${getBuildBranch()}] Drools", [env.DROOLS_CI_EMAIL_TO])
} else {
echo 'No notification sent per configuration'
}
Expand Down
2 changes: 1 addition & 1 deletion .ci/jenkins/dsl/jobs.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void createProjectSetupBranchJob() {
KogitoJobTemplate.createPipelineJob(this, jobParams)?.with {
parameters {
stringParam('DROOLS_VERSION', '', 'Drools version')
booleanParam('DEPLOY_ARTIFACTS', true, 'Deploy artifacts')
booleanParam('DEPLOY', true, 'Deploy artifacts')
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions .ci/jenkins/project/Jenkinsfile.release
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ pipeline {
}
}
}

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
4 changes: 2 additions & 2 deletions .ci/jenkins/project/Jenkinsfile.setup-branch
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ pipeline {
// Launch the nightly to deploy all artifacts from the branch
stage('Launch the nightly') {
when {
expression { return params.DEPLOY_ARTIFACTS }
expression { return params.DEPLOY }
}
steps {
script {
def buildParams = getDefaultBuildParams()
addBooleanParam(buildParams, 'SKIP_TESTS', true)
buildJob('../nightly/0-nightly', buildParams, 'nightly', false)
build(job: '../nightly/0-nightly', wait: false, parameters: buildParams, propagate: false)
}
}
post {
Expand Down