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

BXMSPROD-1231 UMB message body with project version #344

Closed
wants to merge 3 commits into from
Closed
Changes from 2 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
27 changes: 18 additions & 9 deletions .ci/jenkins/Jenkinsfile.prod.nightly
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
@Library('jenkins-pipeline-shared-libraries')_

PME_EXECUTION_RESULT = [:]


pipeline {
agent {
label 'kie-rhel7 && kie-mem24g && !master'
Expand Down Expand Up @@ -62,8 +65,9 @@ pipeline {
'optaweb-employee-rostering-scmRevision': getOptaPlannerBranch(),
]
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, [:])
PME_EXECUTION_RESULT = pmebuild.buildProjects(projectCollection, "${SETTINGS_XML_ID}", "$WORKSPACE/build_config/kogito/nightly", "${env.PME_CLI_PATH}", projectVariableMap, additionalVariables, [:])
}
println "[INFO] PME_EXECUTION_RESULT: ${PME_EXECUTION_RESULT}"
}, 2, 480*60)
}
}
Expand All @@ -72,7 +76,7 @@ pipeline {
stage('Generate Properties Files') {
steps {
script {
if(env.ALREADY_BUILT_PROJECTS?.trim()) {
if(PME_EXECUTION_RESULT?.size()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(PME_EXECUTION_RESULT?.size()) {
if(PME_EXECUTION_RESULT) {

should be enough there or ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be the case where map is empty and if(PME_EXECUTION_RESULT) so the size will assure the PME_EXECUTION_RESULT will have real content

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well if map is empty, if(PME_EXECUTION_RESULT) will consider false

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: [
Expand All @@ -93,7 +97,7 @@ pipeline {
stage('Upload Files to repository') {
steps {
script {
if(env.ALREADY_BUILT_PROJECTS?.trim()) {
if(PME_EXECUTION_RESULT?.findAll{ it.value != null }.size()) {
echo "[INFO] Start uploading ${env.WORKSPACE}/deployDirectory"
if(fileExists("${env.WORKSPACE}/deployDirectory")){
dir("${env.WORKSPACE}/deployDirectory") {
Expand All @@ -112,14 +116,14 @@ pipeline {
stage ('Send UMB Message to QE.') {
steps {
script {
if(env.ALREADY_BUILT_PROJECTS?.trim()) {
if(PME_EXECUTION_RESULT?.size()) {
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)
def messageBody = getMessageBody(propertiesFileUrl, PME_EXECUTION_RESULT)
echo "[INFO] Message Body: ${messageBody}"
echo "[INFO] Topic: ${topic}"
echo "[INFO] Event Type: ${eventType}"
Expand Down Expand Up @@ -170,13 +174,18 @@ pipeline {
}
}

def getMessageBody(String propertiesFileUrl, String alreadyBuiltProjects) {
def alreadyBuiltProjectsArray = (alreadyBuiltProjects ?: '').split(";")
/**
*
* @param propertiesFileUrl the propertiesFile URL
* @param pmeExecutionResult the PME execution map [projectName: projectVersion]
* @return the UMB message body composed the propertiesFileUrl and the builtProjects containing the projectName: projectVersion map
*/
def getMessageBody(String propertiesFileUrl, Map pmeExecutionResult) {
return """
{
"propertiesFileUrl": "${propertiesFileUrl}",
"builtProjects": ${new groovy.json.JsonBuilder(alreadyBuiltProjectsArray).toString()}
}"""
"builtProjects": ${new groovy.json.JsonBuilder(pmeExecutionResult).toString()}
Ginxo marked this conversation as resolved.
Show resolved Hide resolved
}"""
}

def treatGitHashes(String gitInformationHashes) {
Expand Down