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-drools.git
The following commit(s) were added to refs/heads/kie-issues_821 by this push:
new 1028663fa5 Weekly job trigger
1028663fa5 is described below
commit 1028663fa5c387e15c606aee7004d954b72517c2
Author: Rodrigo Antunes <[email protected]>
AuthorDate: Mon Jan 22 08:35:48 2024 -0300
Weekly job trigger
---
.ci/jenkins/dsl/jobs.groovy | 20 ++++
.ci/jenkins/project/Jenkinsfile.weekly | 164 +++++++++++++++++++++++++++++++++
2 files changed, 184 insertions(+)
diff --git a/.ci/jenkins/dsl/jobs.groovy b/.ci/jenkins/dsl/jobs.groovy
index 179cbbf36b..ea013d0f4d 100644
--- a/.ci/jenkins/dsl/jobs.groovy
+++ b/.ci/jenkins/dsl/jobs.groovy
@@ -34,6 +34,9 @@ createProjectSetupBranchJob()
// Nightly jobs
setupProjectNightlyJob()
+// Weekly jobs
+setupProjectWeeklyJob()
+
// Release jobs
setupProjectReleaseJob()
setupProjectPostReleaseJob()
@@ -80,6 +83,23 @@ void setupProjectNightlyJob() {
}
}
+void setupProjectWeeklyJob() {
+ def jobParams = JobParamsUtils.getBasicJobParams(this, '0-weekly',
JobType.OTHER, "${jenkins_path_project}/Jenkinsfile.weekly", 'Drools Weekly')
+ jobParams.triggers = [cron : '0 3 * * 0']
+ jobParams.env.putAll([
+ JENKINS_EMAIL_CREDS_ID: "${JENKINS_EMAIL_CREDS_ID}",
+
+ GIT_BRANCH_NAME: "${GIT_BRANCH}",
+
+ DROOLS_STREAM: Utils.getStream(this),
+ ])
+ KogitoJobTemplate.createPipelineJob(this, jobParams)?.with {
+ parameters {
+ booleanParam('SKIP_TESTS', false, 'Skip all tests')
+ }
+ }
+}
+
void setupProjectReleaseJob() {
def jobParams = JobParamsUtils.getBasicJobParams(this, '0-drools-release',
JobType.RELEASE, "${jenkins_path_project}/Jenkinsfile.release", 'Drools/Kogito
Artifacts Release')
jobParams.env.putAll([
diff --git a/.ci/jenkins/project/Jenkinsfile.weekly
b/.ci/jenkins/project/Jenkinsfile.weekly
new file mode 100644
index 0000000000..41a79934d8
--- /dev/null
+++ b/.ci/jenkins/project/Jenkinsfile.weekly
@@ -0,0 +1,164 @@
+import org.jenkinsci.plugins.workflow.libs.Library
+
+@Library('jenkins-pipeline-shared-libraries')_
+
+// Deploy jobs
+DROOLS_DEPLOY = 'drools.weekly-deploy'
+// KIE_JPMML_INTEGRATION_DEPLOY = 'kie-jpmml-integration.build-and-deploy' //
Commented as not migrated for now
+
+// 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: 360, unit: 'MINUTES')
+ }
+
+ environment {
+ DROOLS_CI_EMAIL = credentials("${JENKINS_EMAIL_CREDS_ID}")
+
+ // Use branch name in weekly tag as we may have parallel main and
release branch builds
+ 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 Drools') {
+ steps {
+ script {
+ def buildParams = getDefaultBuildParams()
+ addSkipTestsParam(buildParams)
+ addSkipIntegrationTestsParam(buildParams)
+
+ buildJob(DROOLS_DEPLOY, buildParams)
+ }
+ }
+ post {
+ failure {
+ addFailedStage(DROOLS_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'
+}
+
+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}"
+
+ paramsStr = ''
+ if (params.SKIP_TESTS) {
+ paramsStr += '\n- Tests skipped'
+ }
+ bodyMsg += paramsStr ? "\n\nConfiguration:${paramsStr}" : '\n'
+
+ 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.DROOLS_CI_EMAIL
+}
+
+List getDefaultBuildParams() {
+ List params = []
+ addStringParam(params, 'DISPLAY_NAME', "${env.WEEKLY_TAG}")
+ addStringParam(params, 'GIT_CHECKOUT_DATETIME', getCheckoutDatetime())
+ 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 buildParams, String key, String value) {
+ buildParams.add(string(name: key, value: value))
+}
+
+void addBooleanParam(List buildParams, String key, boolean value) {
+ buildParams.add(booleanParam(name: key, value: value))
+}
+
+String getBuildBranch() {
+ return env.GIT_BRANCH_NAME
+}
+
+String getCurrentDate() {
+ return sh(returnStdout: true, script: 'date -u "+%Y-%m-%d"').trim()
+}
+
+String getCheckoutDatetime() {
+ return getCurrentDate() + ' 02:00' // Cut-off 02:00AM
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]