This is an automated email from the ASF dual-hosted git repository.
rantunes pushed a commit to branch kie-issues_821
in repository
https://gitbox.apache.org/repos/asf/incubator-kie-kogito-pipelines.git
The following commit(s) were added to refs/heads/kie-issues_821 by this push:
new ca6b718d Weekly jobs
ca6b718d is described below
commit ca6b718dc32c5001532bd0777a397ddf2ae35e4f
Author: Rodrigo Antunes <[email protected]>
AuthorDate: Fri Jan 19 08:35:38 2024 -0300
Weekly jobs
---
.ci/jenkins/Jenkinsfile.weekly | 213 +++++++++++++++++++++++++++++++++++++++++
.ci/jenkins/dsl/jobs.groovy | 21 ++++
2 files changed, 234 insertions(+)
diff --git a/.ci/jenkins/Jenkinsfile.weekly b/.ci/jenkins/Jenkinsfile.weekly
new file mode 100644
index 00000000..e9cb5c8b
--- /dev/null
+++ b/.ci/jenkins/Jenkinsfile.weekly
@@ -0,0 +1,213 @@
+import org.jenkinsci.plugins.workflow.libs.Library
+
+@Library('jenkins-pipeline-shared-libraries')_
+
+// Deploy jobs
+DROOLS_DEPLOY =
'KIE/test/kie-issues_821_drools/kie-issues_821/other/drools.weekly-deploy'
+RUNTIMES_DEPLOY = 'kogito-runtimes.weekly-deploy'
+APPS_DEPLOY = 'kogito-apps.weekly-deploy'
+
+// Map of executed jobs
+// See
https://javadoc.jenkins.io/plugin/workflow-support/org/jenkinsci/plugins/workflow/support/steps/build/RunWrapper.html
+// for more options on built job entity
+JOBS = [:]
+
+FAILED_STAGES = [:]
+UNSTABLE_STAGES = [:]
+
+// Should be multibranch pipeline
+pipeline {
+ agent {
+ label 'ubuntu'
+ }
+
+ options {
+ timeout(time: 900, unit: 'MINUTES')
+ }
+
+ // parameters {
+ // For parameters, check into ./dsl/jobs.groovy file
+ // }
+
+ environment {
+ // Some generated env is also defined into ./dsl/jobs.groovy file
+ KOGITO_CI_EMAIL_TO = credentials("${JENKINS_EMAIL_CREDS_ID}")
+
+ WEEKLY_TAG = """${getBuildBranch()}-${sh(
+ returnStdout: true,
+ script: 'date -u "+%Y-%m-%d"'
+ ).trim()}"""
+ }
+
+ stages {
+ stage('Initialize') {
+ steps {
+ script {
+ echo "weekly tag is ${env.WEEKLY_TAG}"
+
+ currentBuild.displayName = env.WEEKLY_TAG
+ }
+ }
+ }
+
+ stage('Build & Deploy artifacts') {
+ stage('Build & Deploy Drools') {
+ steps {
+ script {
+ def buildParams = getDefaultBuildParams()
+ addSkipTestsParam(buildParams)
+ addSkipIntegrationTestsParam(buildParams)
+ buildJob(DROOLS_DEPLOY, buildParams)
+ }
+ }
+ post {
+ failure {
+ addFailedStage(DROOLS_DEPLOY)
+ }
+ }
+ }
+
+ stage('Build & Deploy Kogito Runtimes') {
+ steps {
+ script {
+ def buildParams = getDefaultBuildParams()
+ addSkipTestsParam(buildParams)
+ addSkipIntegrationTestsParam(buildParams)
+ buildJob(RUNTIMES_DEPLOY, buildParams)
+ }
+ }
+ post {
+ failure {
+ addFailedStage(RUNTIMES_DEPLOY)
+ }
+ }
+ }
+
+ stage('Build & Deploy Kogito Apps') {
+ steps {
+ script {
+ def buildParams = getDefaultBuildParams()
+ addSkipTestsParam(buildParams)
+ addSkipIntegrationTestsParam(buildParams)
+ buildJob(APPS_DEPLOY, buildParams)
+ }
+ }
+ post {
+ failure {
+ addFailedStage(APPS_DEPLOY)
+ }
+ }
+ }
+ }
+ }
+ post {
+ unsuccessful {
+ sendPipelineErrorNotification()
+ }
+ }
+}
+
+def buildJob(String jobName, List buildParams, String jobKey = jobName) {
+ echo "[${jobKey}] Build ${jobName} with params ${buildParams}"
+
+ def job = build(job: "${jobName}", wait: true, parameters: buildParams,
propagate: false)
+ JOBS[jobKey] = job
+
+ // Set Unstable if job did not succeed
+ if (!isJobSucceeded(jobKey)) {
+ addUnstableStage(jobKey)
+ unstable("Job ${jobName} finished with result ${job.result}")
+ }
+ return job
+}
+
+def getJob(String jobKey) {
+ return JOBS[jobKey]
+}
+
+String getJobUrl(String jobKey) {
+ echo "getJobUrl for ${jobKey}"
+ return getJob(jobKey)?.absoluteUrl ?: ''
+}
+
+boolean isJobSucceeded(String jobKey) {
+ return getJob(jobKey)?.result == 'SUCCESS'
+}
+
+boolean isJobUnstable(String jobKey) {
+ return getJob(jobKey)?.result == 'UNSTABLE'
+}
+
+void addFailedStage(String jobKey = '') {
+ FAILED_STAGES.put("${env.STAGE_NAME}", jobKey)
+}
+void addUnstableStage(String jobKey = '') {
+ UNSTABLE_STAGES.put("${env.STAGE_NAME}", jobKey)
+}
+
+void sendPipelineErrorNotification() {
+ String bodyMsg = "Kogito weekly job #${env.BUILD_NUMBER} was:
${currentBuild.currentResult}"
+
+ if (FAILED_STAGES.size() > 0) {
+ bodyMsg += '\nFailed stages: \n- '
+ bodyMsg += FAILED_STAGES.collect { "${it.key} =>
${getJobUrl(it.value)}" }.join('\n- ')
+ }
+ bodyMsg += '\n'
+ if (UNSTABLE_STAGES.size() > 0) {
+ bodyMsg += '\nUnstable stages: \n- '
+ bodyMsg += UNSTABLE_STAGES.collect { "${it.key} =>
${getJobUrl(it.value)}" }.join('\n- ')
+ }
+ bodyMsg += '\n'
+ bodyMsg += "\nPlease look here: ${env.BUILD_URL}"
+ emailext body: bodyMsg, subject: "[${getBuildBranch()}][d] Full Pipeline",
+ to: env.KOGITO_CI_EMAIL_TO
+}
+
+List getDefaultBuildParams() {
+ List params = []
+ addStringParam(params, 'DISPLAY_NAME', env.WEEKLY_TAG)
+ addStringParam(params, 'GIT_CHECKOUT_DATE', getCheckoutDate())
+ addBooleanParam(params, 'SEND_NOTIFICATION', true)
+
+ return params
+}
+
+void addSkipTestsParam(buildParams) {
+ addBooleanParam(buildParams, 'SKIP_TESTS', params.SKIP_TESTS)
+}
+
+void addSkipIntegrationTestsParam(buildParams) {
+ addBooleanParam(buildParams, 'SKIP_INTEGRATION_TESTS', params.SKIP_TESTS)
+}
+
+void addStringParam(List params, String key, String value) {
+ params.add(string(name: key, value: value))
+}
+
+void addBooleanParam(List params, String key, boolean value) {
+ params.add(booleanParam(name: key, value: value))
+}
+
+String getBuildBranch() {
+ return env.GIT_BRANCH_NAME
+}
+
+String getGitAuthor() {
+ return env.GIT_AUTHOR
+}
+
+String getGitAuthorCredsId() {
+ return env.GIT_AUTHOR_CREDS_ID
+}
+
+String getGitAuthorPushCredsId() {
+ return env.GIT_AUTHOR_PUSH_CREDS_ID
+}
+
+String getCurrentDate() {
+ return sh(returnStdout: true, script: 'date -u "+%Y-%m-%d"').trim()
+}
+
+String getCheckoutDatetime() {
+ return getCurrentDate() + ' 02:00' // Cut-off 02:00AM
+}
diff --git a/.ci/jenkins/dsl/jobs.groovy b/.ci/jenkins/dsl/jobs.groovy
index 39496a8b..9b97e677 100644
--- a/.ci/jenkins/dsl/jobs.groovy
+++ b/.ci/jenkins/dsl/jobs.groovy
@@ -61,6 +61,9 @@ if (isMainStream()) {
setupNightlyCloudJob()
}
+// Weekly
+setupWeeklyJob()
+
// Release
setupReleaseArtifactsJob()
setupReleaseCloudJob()
@@ -171,6 +174,24 @@ void setupNightlyJob() {
}
}
+void setupWeeklyJob() {
+ def jobParams = JobParamsUtils.getBasicJobParams(this, '0-kogito-weekly',
JobType.OTHER, "${jenkins_path}/Jenkinsfile.weekly", 'Kogito Weekly')
+ jobParams.triggers = [cron : '0 4 * * 0']
+ jobParams.env.putAll([
+ JENKINS_EMAIL_CREDS_ID: "${JENKINS_EMAIL_CREDS_ID}",
+
+ GIT_BRANCH_NAME: "${GIT_BRANCH}",
+ GIT_AUTHOR: "${GIT_AUTHOR_NAME}",
+ GIT_AUTHOR_CREDS_ID: "${GIT_AUTHOR_CREDENTIALS_ID}",
+ GIT_AUTHOR_PUSH_CREDS_ID: "${GIT_AUTHOR_PUSH_CREDENTIALS_ID}",
+ ])
+ KogitoJobTemplate.createPipelineJob(this, jobParams)?.with {
+ parameters {
+ booleanParam('SKIP_TESTS', false, 'Skip all tests')
+ }
+ }
+}
+
void setupNightlyCloudJob() {
def jobParams = JobParamsUtils.getBasicJobParams(this,
'0-kogito-nightly-cloud', JobType.NIGHTLY,
"${jenkins_path}/Jenkinsfile.nightly.cloud", 'Kogito Nightly')
jobParams.env.putAll([
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]