forked from apache/incubator-kie-kogito-pipelines
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.prod.nightly
147 lines (143 loc) · 7.75 KB
/
Jenkinsfile.prod.nightly
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
@Library('jenkins-pipeline-shared-libraries')_
pipeline {
agent {
label 'kie-rhel7 && kie-mem24g && !master'
}
tools {
maven 'kie-maven-3.6.3'
jdk 'kie-jdk11'
}
parameters {
string(description: 'The deployment URL', name: 'KOGITO_DEPLOYMENT_REPO_URL')
booleanParam(description: 'Skip Tests? True as default', name: 'SKIP_TESTS', defaultValue: true)
string(description: 'The UMB message version', name: 'UMB_VERSION', defaultValue: 'master')
string(description: 'The product version', name: 'PRODUCT_VERSION')
string(description: 'The optaplanner product version', name: 'OPTAPLANNER_PRODUCT_VERSION')
}
options {
buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10')
}
environment {
DATE_TIME_SUFFIX_FORMAT = 'yyyyMMddHH'
}
stages {
stage('Initialize') {
steps {
sh 'printenv'
}
}
stage('Clone build configuration repo') {
steps {
script {
def currentBranch = env.BRANCH_NAME ?: env.GIT_BRANCH
println "Checking out ${env.BUILD_CONFIGURATION_REPO_URL}:${currentBranch} into build_config folder"
sh "git clone -b ${currentBranch} --single-branch ${env.BUILD_CONFIGURATION_REPO_URL} build_config"
}
}
}
stage('Build Nightly projects') {
steps {
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE')
{
script {
def pipelineHelper = new PipelineHelper(this)
pipelineHelper.retry(
{
def SETTINGS_XML_ID = "5d9884a1-178a-4d67-a3ac-9735d2df2cef"
def projectCollection = ["kogito-runtimes", "optaplanner", "kogito-examples"]
def projectVariableMap = [:]
def additionalVariables = ["optaplannerProductVersion": env.OPTAPLANNER_PRODUCT_VERSION]
configFileProvider([configFile(fileId: "49737697-ebd6-4396-9c22-11f7714808eb", variable: 'PRODUCTION_PROJECT_LIST')]) {
pmebuild.buildProjects(projectCollection, "${SETTINGS_XML_ID}", "$WORKSPACE/build_config/kogito/nightly", "${env.PME_CLI_PATH}", projectVariableMap, additionalVariables, [:])
}
}, 2, 480*60)
}
}
}
}
stage('Generate Properties Files') {
steps {
script {
def PME_BUILD_VARIABLES = env.PME_BUILD_VARIABLES.split(";").collect{ it.split("=")}.inject([:]) {map, item -> map << [(item.length == 2 ? item[0] : null): (item.length == 2 ? item[1] : null)]}
build job: env.KOGITO_PROPERTIES_GENERATOR_PATH, parameters: [
[$class: 'BooleanParameterValue', name: 'IS_PROD', value: false],
[$class: 'StringParameterValue', name: 'BRANCH_NAME', value: env.BRANCH_NAME],
[$class: 'StringParameterValue', name: 'KOGITO_PRODUCT_VERSION', value: PME_BUILD_VARIABLES['productVersion']],
[$class: 'StringParameterValue', name: 'OPTAPLANNER_PRODUCT_VERSION', value: PME_BUILD_VARIABLES['optaplannerProductVersion']],
[$class: 'StringParameterValue', name: 'TIME_STAMP', value: "${PME_BUILD_VARIABLES['datetimeSuffix']}"]
]
}
}
}
stage('Upload Files to repository') {
steps {
script {
echo "[INFO] Start uploading ${env.WORKSPACE}/deployDirectory"
if(fileExists("${env.WORKSPACE}/deployDirectory")){
dir("${env.WORKSPACE}/deployDirectory") {
withCredentials([usernameColonPassword(credentialsId: "${env.NIGHTLY_DEPLOYMENT_CREDENTIAL}", variable: 'deploymentCredentials')]) {
sh "zip -r kogito ."
sh "curl --upload-file kogito.zip -u $deploymentCredentials -v ${KOGITO_DEPLOYMENT_REPO_URL}"
}
}
}
}
}
}
stage ("Send UMB Message to QE.") {
steps {
script {
echo "[INFO] Sending KOGITO UMB message to QE."
def PME_BUILD_VARIABLES = env.PME_BUILD_VARIABLES.split(";").collect{ it.split("=")}.inject([:]) {map, item -> map << [(item.length == 2 ? item[0] : null): (item.length == 2 ? item[1] : null)]}
def propertiesFileUrl = "${env.STAGING_SERVER_URL}/kogito/KOGITO-${PME_BUILD_VARIABLES['productVersion']}.${PME_BUILD_VARIABLES['milestone']}/kogito-${PME_BUILD_VARIABLES['datetimeSuffix']}.properties"
def topic = "VirtualTopic.qe.ci.ba.kogito.${env.UMB_VERSION}.nightly.trigger"
def eventType = "kogito-${env.UMB_VERSION}-nightly-qe-trigger"
def messageBody = getMessageBody(propertiesFileUrl, env.ALREADY_BUILT_PROJECTS)
echo "[INFO] Message Body: ${messageBody}"
echo "[INFO] Topic: ${topic}"
echo "[INFO] Event Type: ${eventType}"
build job: env.SEND_UMB_MESSAGE_JOB_PATH, parameters: [
[$class: 'StringParameterValue', name: 'MESSAGE_BODY', value: messageBody],
[$class: 'StringParameterValue', name: 'TOPIC', value: topic],
[$class: 'StringParameterValue', name: 'EVENT_TYPE', value: eventType]
]
echo "[SUCCESS] Message was successfully sent."
}
}
}
}
post {
failure {
emailext body: 'Kogito ${PRODUCT_VERSION}:nightly-build #${BUILD_NUMBER} was: ' + "${currentBuild.currentResult}" + '\n' +
'Please look here: ${BUILD_URL} \n' +
' \n' +
'${BUILD_LOG, maxLines=750}', subject: 'Kogito ${PRODUCT_VERSION}:nightly-build #${BUILD_NUMBER}: ' + "${currentBuild.currentResult}", to: '[email protected]'
}
unstable {
emailext body: 'Kogito ${PRODUCT_VERSION}:nightly-build #${BUILD_NUMBER} was: ' + "${currentBuild.currentResult}" + '\n' +
'Please look here: ${BUILD_URL} \n' +
' \n' +
'Failed tests: ${BUILD_URL}/testReport \n' +
' \n' +
'${BUILD_LOG, maxLines=750}', subject: 'Kogito ${PRODUCT_VERSION}:nightly-build #${BUILD_NUMBER}: ' + "${currentBuild.currentResult}", to: '[email protected]'
}
fixed {
emailext body: 'Kogito ${PRODUCT_VERSION}:nightly-build #${BUILD_NUMBER} was: ' + "${currentBuild.currentResult}" + '\n' +
'Please look here: ${BUILD_URL}', subject: 'Kogito ${PRODUCT_VERSION}:nightly-build #${BUILD_NUMBER}: ' + "${currentBuild.currentResult}", to: '[email protected]'
}
always {
archiveArtifacts artifacts: '**/*.maven.log', fingerprint: false, defaultExcludes: true, caseSensitive: true, allowEmptyArchive: true
}
cleanup {
cleanWs()
}
}
}
def getMessageBody(String propertiesFileUrl, String alreadyBuiltProjects) {
def alreadyBuiltProjectsArray = (alreadyBuiltProjects ?: '').split(";")
return """
{
"propertiesFileUrl": "${propertiesFileUrl}",
"builtProjects": ${new groovy.json.JsonBuilder(alreadyBuiltProjectsArray).toString()}
}"""
}