blob: b223e3d00b3f247a373a31cf640b716ac4670649 [file] [log] [blame]
@Library('jenkins-pipeline-shared-libraries')_
settingsXMLId = 'kogito-tooling-prod'
pipeline {
agent {
label 'kie-rhel8 && kie-mem16g && !master'
}
tools {
nodejs "nodejs-16.2.0"
jdk "kie-jdk11"
}
parameters {
string(description: 'The deployment URL', name: 'DEPLOYMENT_REPO_URL')
booleanParam(description: 'Skip Tests? True as default', name: 'SKIP_TESTS', defaultValue: true)
string(description: 'The product version', name: 'PRODUCT_VERSION', defaultValue: "1.0.0")
string(description: 'The UMB message version', name: 'UMB_VERSION', defaultValue: 'main')
}
options {
buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10')
}
stages {
stage('Initialize') {
steps {
sh 'printenv'
}
}
stage('Clone build configuration repo') {
steps {
script {
def currentBranch = env.BRANCH_NAME ?: env.GIT_BRANCH
currentBranch = currentBranch == 'main' ? 'master' : currentBranch
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('npm login') {
steps {
withCredentials([usernamePassword(credentialsId: "npmRegistryPublish", usernameVariable: 'NPM_USER', passwordVariable: 'NPM_PASSWORD')]) {
sh "npm-cli-login -u $NPM_USER -p $NPM_PASSWORD -e kie@redhat.com -r $NPM_REGISTRY_PUBLISH_URL"
}
}
}
stage('prepare kogito-tooling dependencies') {
steps {
script {
env['EXTERNAL_RESOURCE_PATH__bpmnEditor'] = "$WORKSPACE/kiegroup_kogito-editors-java/kie-wb-common-stunner/kie-wb-common-stunner-sets/kie-wb-common-stunner-bpmn/kie-wb-common-stunner-bpmn-kogito-runtime/target/kie-wb-common-stunner-bpmn-kogito-runtime"
env['EXTERNAL_RESOURCE_PATH__dmnEditor'] = "$WORKSPACE/kiegroup_kogito-editors-java/kie-wb-common-dmn/kie-wb-common-dmn-webapp-kogito-runtime/target/kie-wb-common-dmn-webapp-kogito-runtime"
env['EXTERNAL_RESOURCE_PATH__scesimEditor'] = "$WORKSPACE/kiegroup_kogito-editors-java/drools-wb-screens/drools-wb-scenario-simulation-editor/drools-wb-scenario-simulation-editor-kogito-runtime/target/drools-wb-scenario-simulation-editor-kogito-runtime"
}
}
}
stage('Build Nightly projects') {
steps {
script {
def projectCollection = ["kiegroup/kogito-editors-java", "kiegroup/kogito-tooling"]
println "Project Collection to build ${projectCollection}"
def buildConfigAdditionalVariables = [:]
def buildConfigPathFolder = "$WORKSPACE/build_config/kogito/nightly"
Map<String, Object> buildConfigMap = getBuildConfigMap(buildConfigPathFolder, buildConfigAdditionalVariables)
pmebuild.checkoutProjects(projectCollection, buildConfigMap, buildConfigAdditionalVariables)
projectCollection.each { project -> buildProject(project, buildConfigMap) }
}
}
}
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 -r kogito-tooling ."
sh "curl --upload-file kogito-tooling.zip -u $deploymentCredentials -v ${DEPLOYMENT_REPO_URL}"
}
}
}
}
}
stage ("Send Kogito-tooling UMB Message to QE.") {
steps {
script {
echo "[INFO] Sending kogito-tooling UMB message to QE."
def messageBody = """
{
\"npmRegistry\": \"${NPM_REGISTRY_PUBLISH_URL}",
\"versions\": {
\"kogito-tooling\": \"${env.CURRENT_KOGITO_TOOLING_VERSION}\",
\"kogito-editors-java\": \"${env.KOGITO_EDITORS_JAVA_VERSION}\"
}
}
"""
def topic = "VirtualTopic.qe.ci.ba.kogito-tooling.${env.UMB_VERSION}.nightly.trigger"
def eventType = "kogito-tooling-${env.UMB_VERSION}-nightly-qe-trigger"
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-tooling nightly-build #${BUILD_NUMBER} was: ' + "${currentBuild.currentResult}" + '\n' +
'Please look here: ${BUILD_URL} \n' +
' \n' +
'${BUILD_LOG, maxLines=750}', subject: 'kogito-tooling nightly-build #${BUILD_NUMBER}: ' + "${currentBuild.currentResult}", to: 'kie-jenkins-builds@redhat.com'
}
unstable {
emailext body: 'kogito-tooling 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-tooling nightly-build #${BUILD_NUMBER}: ' + "${currentBuild.currentResult}", to: 'kie-jenkins-builds@redhat.com'
}
fixed {
emailext body: 'kogito-tooling nightly-build #${BUILD_NUMBER} was: ' + "${currentBuild.currentResult}" + '\n' +
'Please look here: ${BUILD_URL}', subject: 'kogito-tooling nightly-build #${BUILD_NUMBER}: ' + "${currentBuild.currentResult}", to: 'kie-jenkins-builds@redhat.com'
}
cleanup {
cleanWs()
}
}
}
def getBuildConfigMap(def buildConfigPathFolder, def buildConfigAdditionalVariables){
env.DATE_TIME_SUFFIX = env.DATE_TIME_SUFFIX ?: "${new Date().format('yyyyMMdd')}"
env.PME_BUILD_VARIABLES = ''
def buildConfigContent = readFile "${buildConfigPathFolder}/build-config.yaml"
return pmebuild.getBuildConfiguration(buildConfigContent, buildConfigPathFolder, buildConfigAdditionalVariables)
}
def buildProject(String project, Map<String, Object> buildConfig, String defaultGroup = "kiegroup") {
println "[INFO] Building project ${project}"
if ("kiegroup/kogito-tooling" == project) {
env.CURRENT_KOGITO_TOOLING_VERSION = env.CURRENT_KOGITO_TOOLING_VERSION ?: sh(returnStdout: true, script: 'awk -F\'"\' \'/"version": ".+"/{ print $4; exit; }\' lerna.json')?.trim() + "-redhat-${env.DATE_TIME_SUFFIX}"
println "kogito-tooling prod version ${env.CURRENT_KOGITO_TOOLING_VERSION}"
}
def projectGroupName = util.getProjectGroupName(project, defaultGroup)
def group = projectGroupName[0]
def name = projectGroupName[1]
dir("${env.WORKSPACE}/${group}_${name}") {
if (fileExists("./pom.xml")) {
pmebuild.executePME(project, pmebuild.getProjectConfiguration(project, buildConfig), "${env.PME_CLI_PATH}", settingsXMLId, [:])
def pom = readMavenPom file: 'pom.xml'
env["${name}-VERSION".replace("-", "_").toUpperCase()] = pom.version ?: pom.parent.version
}
pmebuild.executeBuildScript(project, buildConfig, settingsXMLId, "-DaltDeploymentRepository=local::default::file://${env.WORKSPACE}/deployDirectory")
}
}