Skip to content

Commit

Permalink
Creating ENV_REPO_DIR_NAME.
Browse files Browse the repository at this point in the history
  • Loading branch information
bacciotti committed Aug 3, 2023
1 parent 6fbe197 commit b50f076
Showing 1 changed file with 39 additions and 12 deletions.
51 changes: 39 additions & 12 deletions .jenkins/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
Expand Down Expand Up @@ -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"

Expand All @@ -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 (
Expand Down Expand Up @@ -118,24 +118,51 @@ 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"
}
}
}
}
}
}
}


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 {
Expand Down

0 comments on commit b50f076

Please sign in to comment.