-
Notifications
You must be signed in to change notification settings - Fork 414
/
Copy pathJenkinsfile.nightly
188 lines (178 loc) · 10.4 KB
/
Jenkinsfile.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
@Library('jenkins-pipeline-shared-libraries')_
localNexusRepositoryId = "${env.LOCAL_NEXUS_REPOSITORY_ID?.trim() ? LOCAL_NEXUS_REPOSITORY_ID : 'rhba-main-nightly'}"
def tagName = "nightly-${PRODUCT_VERSION}.redhat-${new Date().format('yyyyMMddHHmm')}"
pipeline {
agent {
label 'kie-rhel8 && kie-mem24g && !built-in'
}
tools {
maven 'kie-maven-3.8.1'
jdk 'kie-jdk11'
}
environment {
LOCAL_NEXUS_REPOSITORY_ID = "${localNexusRepositoryId}"
}
parameters {
string(description: 'The deployment URL', name: 'KIE_GROUP_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: 'main')
string(description: 'The product version', name: 'PRODUCT_VERSION')
string(description: 'The config repository branch', name: 'CONFIG_BRANCH', defaultValue: 'main')
}
options {
buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10')
timestamps()
}
stages {
stage('Initialize') {
steps {
sh 'printenv'
}
}
stage('Remove partially downloaded deps') {
steps {
script{
util.rmPartialDeps()
}
}
}
stage('Clone build configuration repo') {
steps {
script {
def currentBranch = env.CONFIG_BRANCH ?: env.DEFAULT_CONFIG_BRANCH ?: 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 {
script {
def SETTINGS_XML_ID = "rhba-prod-main"
// This is the map project, variable to store the version from this project
def repositoryListPath = "./script/repository-list.txt"
def branched7RepositoryListPath = "./script/branched-7-repository-list.txt"
def projectVariableMap = ['kiegroup_droolsjbpm-build-bootstrap': "kieVersion", 'jboss-integration_izpack': "izpackVersion", 'jboss-integration_installer-commons': "installerCommonsVersion"]
configFileProvider([configFile(fileId: "49737697-ebd6-4396-9c22-11f7714808eb", variable: 'PRODUCTION_PROJECT_LIST')]) {
println "Reading file ${repositoryListPath} and merging it with ${PRODUCTION_PROJECT_LIST} jenkins file"
def communityProjectListFile = readFile repositoryListPath
def projectCollection = communityProjectListFile.readLines()
def productionProjectListFile = readFile "${env.PRODUCTION_PROJECT_LIST}"
projectCollection.addAll(productionProjectListFile.readLines())
projectCollection.removeAll { 'droolsjbpm-tools'.equals(it.toLowerCase()) } // The droolsjbpm-tools is skiped
println "File ${repositoryListPath} and ${env.PRODUCTION_PROJECT_LIST} jenkins file merged in ${projectCollection}"
def currentBranch = env.BRANCH_NAME ?: env.GIT_BRANCH
def additionalVariables = [:]
if ('main' == currentBranch) {
def branched7RepositoryListFile = readFile branched7RepositoryListPath
branched7RepositoryListFile.readLines().each { additionalVariables["${it}-scmRevision"] = '7.x' }
}
retry(3) {
timeout(time: 8, unit: 'HOURS') {
pmebuild.buildProjects(projectCollection, "${SETTINGS_XML_ID}", "$WORKSPACE/build_config/rhba/nightly", "${env.PME_CLI_PATH}", projectVariableMap, additionalVariables, [:])
}
}
}
}
}
}
stage ("Create tags in prod repositories") {
steps {
script {
def projectsToTagWithProdRepoName = ["jboss-integration/bxms-patch-tools": "bxms-patch-tools"]
projectsToTagWithProdRepoName.each { project ->
def projectGroupName = util.getProjectGroupName(project.key)
def group = projectGroupName[0]
def name = projectGroupName[1]
dir("${env.WORKSPACE}/${group}_${name}") {
def remoteName = "prod"
githubscm.commitChanges("PME changes for ${tagName}")
githubscm.tagRepository(tagName)
githubscm.addRemote(remoteName, "${env.PRODUCTIZATION_REPOSITORY_BASE_URL}/${project.value}")
githubscm.pushRemoteTag(remoteName, tagName, "gitlab-user")
}
}
}
}
}
stage('Generate RHPAM 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.RHPAM_PROPERTIES_GENERATOR_PATH, parameters: [
[$class: 'BooleanParameterValue', name: 'IS_RELEASE', value: false],
[$class: 'StringParameterValue', name: 'BRANCH_NAME', value: env.BRANCH_NAME],
[$class: 'StringParameterValue', name: 'TAG_HASH', value: tagName],
[$class: 'StringParameterValue', name: 'KIE_VERSION', value: PME_BUILD_VARIABLES['kieVersion']],
[$class: 'StringParameterValue', name: 'PRODUCT_VERSION', value: PME_BUILD_VARIABLES['productVersion']],
[$class: 'StringParameterValue', name: 'TIME_STAMP', value: "${PME_BUILD_VARIABLES['datetimeSuffix']}"],
[$class: 'StringParameterValue', name: 'MVEL_VERSION', value: PME_BUILD_VARIABLES['mvelVersion']],
[$class: 'StringParameterValue', name: 'IZPACK_VERSION', value: PME_BUILD_VARIABLES['izpackVersion']],
[$class: 'StringParameterValue', name: 'INSTALLER_COMMONS_VERSION', value: PME_BUILD_VARIABLES['installerCommonsVersion']]
]
}
}
}
stage('Upload Files to repository') {
steps {
script {
echo "[INFO] Start uploading ${env.WORKSPACE}/deployDirectory"
dir("${env.WORKSPACE}/deployDirectory") {
withCredentials([usernameColonPassword(credentialsId: "${env.NIGHTLY_DEPLOYMENT_CREDENTIAL}", variable: 'deploymentCredentials')]) {
sh "zip -qr kiegroup ."
sh "curl --fail --upload-file kiegroup.zip -u $deploymentCredentials -v ${KIE_GROUP_DEPLOYMENT_REPO_URL}"
}
}
}
}
}
stage ("Send RHPAM UMB Message to QE.") {
steps {
script {
echo "[INFO] Sending RHPAM 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}/rhpam/RHPAM-${PME_BUILD_VARIABLES['productVersion']}.${PME_BUILD_VARIABLES['milestone']}/rhpam-${PME_BUILD_VARIABLES['datetimeSuffix']}.properties"
def topic = "VirtualTopic.qe.ci.ba.rhpam.${env.UMB_VERSION}.nightly.trigger"
def eventType = "rhpam-${env.UMB_VERSION}-nightly-qe-trigger"
echo "[INFO] Message Body: ${propertiesFileUrl}"
echo "[INFO] Topic: ${topic}"
echo "[INFO] Event Type: ${eventType}"
build job: env.SEND_UMB_MESSAGE_JOB_PATH, parameters: [
[$class: 'StringParameterValue', name: 'MESSAGE_BODY', value: propertiesFileUrl],
[$class: 'StringParameterValue', name: 'TOPIC', value: topic],
[$class: 'StringParameterValue', name: 'EVENT_TYPE', value: eventType]
]
echo "[SUCCESS] Message was successfully sent."
}
}
}
}
post {
failure {
emailext body: '${PRODUCT_VERSION}:nightly-build #${BUILD_NUMBER} was: ' + "${currentBuild.currentResult}" + '\n' +
'Please look here: ${BUILD_URL} \n' +
' \n' +
'${BUILD_LOG, maxLines=750}', subject: '${PRODUCT_VERSION}:nightly-build #${BUILD_NUMBER}: ' + "${currentBuild.currentResult}", to: '[email protected]'
}
unstable {
emailext body: '${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: '${PRODUCT_VERSION}:nightly-build #${BUILD_NUMBER}: ' + "${currentBuild.currentResult}", to: '[email protected]'
}
fixed {
emailext body: '${PRODUCT_VERSION}:nightly-build #${BUILD_NUMBER} was: ' + "${currentBuild.currentResult}" + '\n' +
'Please look here: ${BUILD_URL}', subject: '${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 {
script {
util.cleanNode()
}
}
}
}