diff --git a/.jenkins/Jenkinsfile b/.jenkins/Jenkinsfile index bd759fa3..65a4d553 100644 --- a/.jenkins/Jenkinsfile +++ b/.jenkins/Jenkinsfile @@ -14,16 +14,17 @@ pipeline { environment { ENV_AFFECTED_COMPONENTS = '' + ENV_REPO_DIR_NAME = '' GERRIT_CREDENTIALS = credentials('gerrit-user') } parameters { string(description: 'The repo where the patch needs to be applied to.', name: 'PROJECT_REPO', defaultValue: 'git://git.host.prod.eng.bos.redhat.com/kiegroup/drools.git') - string(description: 'The tag corresponding to the product version for which the patch needs to be created', name: 'PRODUCT_TAG', defaultValue: 'RHBA-7.1.0.CR3') + string(description: 'The tag corresponding to the product version for which the patch needs to be created', name: 'PRODUCT_TAG', defaultValue: '7.67.0.Final-redhat-00022') string(description: 'The JIRA ID of the one-off patch.', name: 'PATCH_JIRA_ID', defaultValue: 'RHPAM-5678') string(description: 'The upstream repo where is the patch tag.', name: 'UPSTREAM_REPO', defaultValue: 'https://github.com/kiegroup/drools.git') - string(description: 'The one-off patch branch on upstream.', name: 'BRANCH_PATCH', defaultValue: '7.11.x') - string(description: 'The patch commit hash to backport.', name: 'COMMIT_HASH_TO_BACKPORT', defaultValue: 'bfcf448ef7') + string(description: 'The one-off patch branch on upstream.', name: 'BRANCH_PATCH', defaultValue: '7.67.x') + string(description: 'The patch commit hash to backport.', name: 'COMMIT_HASH_TO_BACKPORT', defaultValue: 'bc54b76e4706f0af272b9e29891e1255c48b8bee') string(description: 'The Gerrit repo where the patch will be pushed.', name: 'GERRIT_REPO_TARGET', defaultValue: 'kiegroup/drools.git') string(description: 'The definitions file to be used on Build Chain.', name: 'BUILD_CHAIN_DEFINITIONS_FILE', defaultValue: 'https://code.engineering.redhat.com/gerrit/gitweb?p=rguimara/pnc-test.git;a=blob_plain;f=definitions-file.yaml;h=87e631fccc00ce74ce791c7eb8a49187e349a638;hb=80b133edf32b94793b8f44aa56997ce755f3477d') } @@ -55,9 +56,9 @@ pipeline { stage('Cd to directory, get tags & cherry-pick') { steps { script { - def newDirName = getNewDirectoryName() + ENV_REPO_DIR_NAME = getNewDirectoryName() - dir ("build_chain/${newDirName}"){ + dir ("build_chain/${ENV_REPO_DIR_NAME}"){ println "[INFO] Fetching origin tags..." sh "git fetch origin --tags" @@ -83,9 +84,8 @@ pipeline { stage('Running PME tool') { steps { script { - def newDirName = getNewDirectoryName() - dir("build_chain/${newDirName}"){ + dir("build_chain/${ENV_REPO_DIR_NAME}"){ println "[INFO] Running PME..." script { AFFECTED_COMPONENTS = sh ( @@ -118,17 +118,19 @@ pipeline { } } + stage('Generate the JAR files') { steps { script { - def newDirName = getNewDirectoryName() - dir("build_chain/${newDirName}/drools-model"){ + dir("build_chain/${ENV_REPO_DIR_NAME}"){ def SETTINGS_XML_ID = '5d9884a1-178a-4d67-a3ac-9735d2df2cef' configFileProvider([configFile(fileId: "${SETTINGS_XML_ID}", variable: 'PME_MAVEN_SETTINGS_XML')]) { ENV_AFFECTED_COMPONENTS.tokenize(",").each { - println "[INFO] cd into ${it}" - sh "pwd && ls -la" - sh "mvn -s ${PME_MAVEN_SETTINGS_XML} clean package -DskipTests" + println "[INFO] cd into ${it}" + dir("${it}"){ + sh "pwd" + sh "mvn -s ${PME_MAVEN_SETTINGS_XML} clean package -DskipTests" + } } } } @@ -136,6 +138,31 @@ pipeline { } } + + stage('Push new branch to target repo') { + steps { + script { + dir("build_chain/${ENV_REPO_DIR_NAME}"){ + println "[INFO] Pushing new branch to target repo..." + githubscm.addRemote('code.engineering', "${env.PRODUCTIZATION_REPOSITORY_BASE_URL}/${params.GERRIT_REPO_TARGET}") + if (githubscm.isThereAnyChanges()) { + githubscm.commitChanges("One-off patch ${params.PATCH_JIRA_ID}") + println "[INFO] Changed files:" + sh "git diff --name-only HEAD~1" + + // Remove comment when in prod. + println "[INFO] Pushing to code.engineering..." + githubscm.pushObject('code.engineering', params.PATCH_JIRA_ID) + + } else { + echo "No changes to push." + } + } + } + } + } + + } post { always {