From f9f13477f9086f3870db48d020f0be7c0f344f4c Mon Sep 17 00:00:00 2001 From: Tung Le Date: Tue, 24 Dec 2024 17:40:38 +0700 Subject: [PATCH 01/13] IVYPORTAL-14419 Raise version of your portal maven artifacts to the next development cycle after release > Increase portal version by build param --- build/update-pom/Jenkinsfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build/update-pom/Jenkinsfile b/build/update-pom/Jenkinsfile index 38ca45c8e1..179ad01efd 100644 --- a/build/update-pom/Jenkinsfile +++ b/build/update-pom/Jenkinsfile @@ -10,7 +10,8 @@ pipeline { parameters { string(name: 'buildPluginVersion', defaultValue: '13.1.0-SNAPSHOT', description: 'Axon Ivy build plugin version of all pom will be updated to.') string(name: 'ivyEngineVersion', defaultValue: '13.1.0', description: 'Axon Ivy engine version of all pom will be updated to.') - string(name: 'branchToPush', defaultValue: 'portal-update-pom/master', description: 'Branch name to push changes. It must not be protected branches. After this build, create a pull request to merge to master') + string(name: 'portalVersion', defaultValue: '13.1.0', description: 'Portal version of all pom will be updated to.') + string(name: 'branchToPush', defaultValue: 'portal-update-pom/master', description: 'Branch name to push changes. It must not be protected branches. After this build, create a pull request to merge to master') string(name: 'engineDownloadURL', defaultValue: '-Divy.engine.download.url=https://developer.axonivy.com/permalink/nightly/axonivy-engine.zip', description: '''Where to download engine? e.g. -Divy.engine.download.url=https://developer.axonivy.com/permalink/nightly/axonivy-engine.zip for nightly master -Divy.engine.download.url=https://developer.axonivy.com/permalink/dev/axonivy-engine.zip for dev master @@ -67,6 +68,7 @@ def updateVersion() { for (pomFile in pomFiles) { maven cmd: "-f ${pomFile} versions:set-property versions:commit -Dproperty=ivy.engine.version -DnewVersion=${params.ivyEngineVersion}" maven cmd: "-f ${pomFile} versions:set-property versions:commit -Dproperty=build.plugin.version -DnewVersion=${params.buildPluginVersion}" + maven cmd: "-f ${pomFile} release:update-versions -DdevelopmentVersion=${params.portalVersion}" } } From b57d67c666670705d013404b9fa70f18c96e370a Mon Sep 17 00:00:00 2001 From: Tung Le Date: Thu, 26 Dec 2024 16:45:43 +0700 Subject: [PATCH 02/13] IVYPORTAL-14419 Raise version of your portal maven artifacts to the next development cycle after release > Increase portal version by build param --- build/update-pom/Jenkinsfile | 50 ++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/build/update-pom/Jenkinsfile b/build/update-pom/Jenkinsfile index 179ad01efd..ea9050c1f5 100644 --- a/build/update-pom/Jenkinsfile +++ b/build/update-pom/Jenkinsfile @@ -34,25 +34,25 @@ pipeline { echo '====================Update version====================' updateVersion() - echo '====================Commit to GIT====================' - changeLog = sh(returnStdout: true, script: 'git status -s').trim() - if (changeLog) { - sh """ - git commit -a -m "Updated all pom build.plugin.version=${params.buildPluginVersion}, ivy.engine.version=${params.ivyEngineVersion}" - git checkout -b ${params.branchToPush} - git push origin -u ${params.branchToPush} - """ - } else { - echo 'Nothing to commit.' - } + // echo '====================Commit to GIT====================' + // changeLog = sh(returnStdout: true, script: 'git status -s').trim() + // if (changeLog) { + // sh """ + // git commit -a -m "Updated all pom build.plugin.version=${params.buildPluginVersion}, ivy.engine.version=${params.ivyEngineVersion}" + // git checkout -b ${params.branchToPush} + // git push origin -u ${params.branchToPush} + // """ + // } else { + // echo 'Nothing to commit.' + // } } } } - echo '====================Cache engine in local repository====================' - removeCacheEngine() - docker.build('fetch-cache', '-f build/Dockerfile .').inside('-v /var/tools/maven-cache:/home/build/') { - maven cmd: 'clean install -f AxonIvyPortal/portal-components/pom.xml' + // echo '====================Cache engine in local repository====================' + // removeCacheEngine() + // docker.build('fetch-cache', '-f build/Dockerfile .').inside('-v /var/tools/maven-cache:/home/build/') { + // maven cmd: 'clean install -f AxonIvyPortal/portal-components/pom.xml' } } } @@ -68,8 +68,26 @@ def updateVersion() { for (pomFile in pomFiles) { maven cmd: "-f ${pomFile} versions:set-property versions:commit -Dproperty=ivy.engine.version -DnewVersion=${params.ivyEngineVersion}" maven cmd: "-f ${pomFile} versions:set-property versions:commit -Dproperty=build.plugin.version -DnewVersion=${params.buildPluginVersion}" - maven cmd: "-f ${pomFile} release:update-versions -DdevelopmentVersion=${params.portalVersion}" } + + powershell ''' + #find all pom file of portal project and change their versions and their portal dependencies to releaseVersion + $utf8WithoutBom = New-Object System.Text.UTF8Encoding($false) + $files = get-childitem AxonIvyPortal/*/pom.xml,Showcase/*/pom.xml,AxonIvyPortal/portal-selenium-test/customized_pom.xml,AxonIvyPortal/portal-selenium-test/document_screenshot_pom.xml,Documentation/public-api/pom.xml + foreach($file in $files) { + $xml = new-object xml + $xml.load($file) + $xml.project.version = $env:portalVersion + $dependencies = $xml.project.dependencies.ChildNodes + foreach($dependency in $dependencies) { + if(($dependency.groupId -eq 'ch.ivyteam.ivy.project.portal') -or ($dependency.groupId -eq 'com.axonivy.portal')) { + $dependency.version = $env:portalVersion + } + } + $sw = New-Object System.IO.StreamWriter($file, $false, $utf8WithoutBom) + $xml.Save($sw) + } + ''' } def removeCacheEngine() { From 3a8d22b2d95345a99ed062a197fdce99e0df37bd Mon Sep 17 00:00:00 2001 From: Tung Le Date: Thu, 26 Dec 2024 16:48:54 +0700 Subject: [PATCH 03/13] IVYPORTAL-14419 Raise version of your portal maven artifacts to the next development cycle after release > Increase portal version by build param --- build/update-pom/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/update-pom/Jenkinsfile b/build/update-pom/Jenkinsfile index ea9050c1f5..1a87453950 100644 --- a/build/update-pom/Jenkinsfile +++ b/build/update-pom/Jenkinsfile @@ -53,7 +53,7 @@ pipeline { // removeCacheEngine() // docker.build('fetch-cache', '-f build/Dockerfile .').inside('-v /var/tools/maven-cache:/home/build/') { // maven cmd: 'clean install -f AxonIvyPortal/portal-components/pom.xml' - } + // } } } } From f3665ed8763d60e26646f9dcc68e7403d5636ab1 Mon Sep 17 00:00:00 2001 From: Tung Le Date: Fri, 27 Dec 2024 09:58:09 +0700 Subject: [PATCH 04/13] IVYPORTAL-14419 Raise version of your portal maven artifacts to the next development cycle after release > Update build update-pom --- build/update-pom/Dockerfile | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 build/update-pom/Dockerfile diff --git a/build/update-pom/Dockerfile b/build/update-pom/Dockerfile new file mode 100644 index 0000000000..e534e0069f --- /dev/null +++ b/build/update-pom/Dockerfile @@ -0,0 +1,8 @@ +FROM maven:3.9.8-eclipse-temurin-21 + +# Create a group and user with the specified IDs +RUN apt-get update && apt-get install -y --no-install-recommends \ + passwd adduser\ + && apt-get install -y openssh-client\ + && addgroup --gid 1001 build && adduser --uid 1001 --gid 1001 --disabled-password --gecos "" build\ + && apt-get install -y python3 From e17c4b6bfdb40dfc871c18e89630d2b2169281a4 Mon Sep 17 00:00:00 2001 From: Tung Le Date: Fri, 27 Dec 2024 11:15:13 +0700 Subject: [PATCH 05/13] IVYPORTAL-14419 Raise version of your portal maven artifacts to the next development cycle after release > Increase portal version by build param --- build/update-pom/Jenkinsfile | 103 +++++++++++++++++++++++++++-------- 1 file changed, 81 insertions(+), 22 deletions(-) diff --git a/build/update-pom/Jenkinsfile b/build/update-pom/Jenkinsfile index 1a87453950..dcde617d99 100644 --- a/build/update-pom/Jenkinsfile +++ b/build/update-pom/Jenkinsfile @@ -23,7 +23,7 @@ pipeline { steps { script { currentBuild.description = "On ${env.NODE_NAME}" - docker.build('update-pom', '-f build/Dockerfile .').inside('-v /var/tools/maven-cache:/home/build/') { + docker.build('update-pom', '-f build/update-pom/Dockerfile .').inside('-v /var/tools/maven-cache:/home/build/') { withEnv(['GIT_SSH_COMMAND=ssh -o StrictHostKeyChecking=no']) { sshagent(credentials: ['github-axonivy']) { sh """ @@ -65,28 +65,87 @@ def updateVersion() { 'AxonIvyPortal/portal-selenium-test/pom.xml', 'AxonIvyPortal/portal-selenium-test/customized_pom.xml', 'AxonIvyPortal/portal-selenium-test/document_screenshot_pom.xml', 'AxonIvyPortal/PortalKitTestHelper/pom.xml', 'Showcase/portal-user-examples/pom.xml', 'Showcase/portal-developer-examples/pom.xml', 'Showcase/InternalSupport/pom.xml', 'Showcase/portal-components-examples/pom.xml'] - for (pomFile in pomFiles) { - maven cmd: "-f ${pomFile} versions:set-property versions:commit -Dproperty=ivy.engine.version -DnewVersion=${params.ivyEngineVersion}" - maven cmd: "-f ${pomFile} versions:set-property versions:commit -Dproperty=build.plugin.version -DnewVersion=${params.buildPluginVersion}" - } + // for (pomFile in pomFiles) { + // maven cmd: "-f ${pomFile} versions:set-property versions:commit -Dproperty=ivy.engine.version -DnewVersion=${params.ivyEngineVersion}" + // maven cmd: "-f ${pomFile} versions:set-property versions:commit -Dproperty=build.plugin.version -DnewVersion=${params.buildPluginVersion}" + // } - powershell ''' - #find all pom file of portal project and change their versions and their portal dependencies to releaseVersion - $utf8WithoutBom = New-Object System.Text.UTF8Encoding($false) - $files = get-childitem AxonIvyPortal/*/pom.xml,Showcase/*/pom.xml,AxonIvyPortal/portal-selenium-test/customized_pom.xml,AxonIvyPortal/portal-selenium-test/document_screenshot_pom.xml,Documentation/public-api/pom.xml - foreach($file in $files) { - $xml = new-object xml - $xml.load($file) - $xml.project.version = $env:portalVersion - $dependencies = $xml.project.dependencies.ChildNodes - foreach($dependency in $dependencies) { - if(($dependency.groupId -eq 'ch.ivyteam.ivy.project.portal') -or ($dependency.groupId -eq 'com.axonivy.portal')) { - $dependency.version = $env:portalVersion - } - } - $sw = New-Object System.IO.StreamWriter($file, $false, $utf8WithoutBom) - $xml.Save($sw) - } + sh '''#!/bin/bash + # Ensure the portalVersion environment variable is set + if [ -z "$portalVersion" ]; then + echo "Error: portalVersion environment variable is not set." + exit 1 + fi + + # Define the file patterns to process + file_patterns=( + "AxonIvyPortal/*/pom.xml" + "Showcase/*/pom.xml" + "AxonIvyPortal/portal-selenium-test/customized_pom.xml" + "AxonIvyPortal/portal-selenium-test/document_screenshot_pom.xml" + "Documentation/public-api/pom.xml" + ) + +# Function to update XML files using Python +update_xml() { + python3 - < + version = root.find("version") + if version is not None: + version.text = portal_version + + # Update dependencies + dependencies = root.find("dependencies") + if dependencies is not None: + for dependency in dependencies.findall("dependency"): + group_id = dependency.find("groupId") + if group_id is not None and group_id.text in [ + "ch.ivyteam.ivy.project.portal", + "com.axonivy.portal", + ]: + version_tag = dependency.find("version") + if version_tag is not None: + version_tag.text = portal_version + + # Write changes back to the file + tree.write(file_path, encoding="utf-8", xml_declaration=True) +except Exception as e: + print(f"Failed to process {file_path}: {e}", file=sys.stderr) +EOF +} + + for pattern in "${file_patterns[@]}"; do + for file in $pattern; do + if [ -f "$file" ]; then + echo "Processing $file" + update_xml "$file" + else + echo "No files matching pattern: $pattern" + fi + done + done + echo "All POM files updated successfully." ''' } From 443e932819dfca50511a02338b7e09cf3d08751c Mon Sep 17 00:00:00 2001 From: Tung Le Date: Fri, 27 Dec 2024 15:37:04 +0700 Subject: [PATCH 06/13] IVYPORTAL-14419 Raise version of your portal maven artifacts to the next development cycle after release > Increase portal version by build param --- build/update-pom/Jenkinsfile | 90 +++++++++++++++++------------------- 1 file changed, 42 insertions(+), 48 deletions(-) diff --git a/build/update-pom/Jenkinsfile b/build/update-pom/Jenkinsfile index dcde617d99..f3684ebcdc 100644 --- a/build/update-pom/Jenkinsfile +++ b/build/update-pom/Jenkinsfile @@ -34,17 +34,17 @@ pipeline { echo '====================Update version====================' updateVersion() - // echo '====================Commit to GIT====================' - // changeLog = sh(returnStdout: true, script: 'git status -s').trim() - // if (changeLog) { - // sh """ - // git commit -a -m "Updated all pom build.plugin.version=${params.buildPluginVersion}, ivy.engine.version=${params.ivyEngineVersion}" - // git checkout -b ${params.branchToPush} - // git push origin -u ${params.branchToPush} - // """ - // } else { - // echo 'Nothing to commit.' - // } + echo '====================Commit to GIT====================' + changeLog = sh(returnStdout: true, script: 'git status -s').trim() + if (changeLog) { + sh """ + git commit -a -m "Updated all pom build.plugin.version=${params.buildPluginVersion}, ivy.engine.version=${params.ivyEngineVersion}" + git checkout -b ${params.branchToPush} + git push origin -u ${params.branchToPush} + """ + } else { + echo 'Nothing to commit.' + } } } } @@ -65,30 +65,22 @@ def updateVersion() { 'AxonIvyPortal/portal-selenium-test/pom.xml', 'AxonIvyPortal/portal-selenium-test/customized_pom.xml', 'AxonIvyPortal/portal-selenium-test/document_screenshot_pom.xml', 'AxonIvyPortal/PortalKitTestHelper/pom.xml', 'Showcase/portal-user-examples/pom.xml', 'Showcase/portal-developer-examples/pom.xml', 'Showcase/InternalSupport/pom.xml', 'Showcase/portal-components-examples/pom.xml'] - // for (pomFile in pomFiles) { - // maven cmd: "-f ${pomFile} versions:set-property versions:commit -Dproperty=ivy.engine.version -DnewVersion=${params.ivyEngineVersion}" - // maven cmd: "-f ${pomFile} versions:set-property versions:commit -Dproperty=build.plugin.version -DnewVersion=${params.buildPluginVersion}" - // } - - sh '''#!/bin/bash - # Ensure the portalVersion environment variable is set - if [ -z "$portalVersion" ]; then - echo "Error: portalVersion environment variable is not set." - exit 1 - fi - - # Define the file patterns to process - file_patterns=( - "AxonIvyPortal/*/pom.xml" - "Showcase/*/pom.xml" - "AxonIvyPortal/portal-selenium-test/customized_pom.xml" - "AxonIvyPortal/portal-selenium-test/document_screenshot_pom.xml" - "Documentation/public-api/pom.xml" - ) + for (pomFile in pomFiles) { + if (!params.ivyEngineVersion?.trim().isEmpty()) { + maven cmd: "-f ${pomFile} versions:set-property versions:commit -Dproperty=ivy.engine.version -DnewVersion=${params.ivyEngineVersion}" + } + if (!params.buildPluginVersion?.trim().isEmpty()) { + maven cmd: "-f ${pomFile} versions:set-property versions:commit -Dproperty=build.plugin.version -DnewVersion=${params.buildPluginVersion}" + } + } + echo '============${params.portalVersion?.trim()} outside' -# Function to update XML files using Python -update_xml() { - python3 - < + root = strip_namespace(root) # By default, tag changes to tag , need removing namespace version = root.find("version") if version is not None: version.text = portal_version - # Update dependencies dependencies = root.find("dependencies") if dependencies is not None: for dependency in dependencies.findall("dependency"): @@ -133,20 +123,24 @@ try: except Exception as e: print(f"Failed to process {file_path}: {e}", file=sys.stderr) EOF -} + # End Python scripts - need correct indentation + } - for pattern in "${file_patterns[@]}"; do - for file in $pattern; do - if [ -f "$file" ]; then - echo "Processing $file" + file_patterns=( + "AxonIvyPortal/*/pom.xml" + "Showcase/*/pom.xml" + "AxonIvyPortal/portal-selenium-test/customized_pom.xml" + "AxonIvyPortal/portal-selenium-test/document_screenshot_pom.xml" + "Documentation/public-api/pom.xml" + ) + + for pattern in "${file_patterns[@]}"; do + for file in $pattern; do update_xml "$file" - else - echo "No files matching pattern: $pattern" - fi + done done - done - echo "All POM files updated successfully." - ''' + ''' + } } def removeCacheEngine() { From 4aeaa99b7fcd621b41562995eaf670150b1733e6 Mon Sep 17 00:00:00 2001 From: Tung Le Date: Fri, 27 Dec 2024 15:48:31 +0700 Subject: [PATCH 07/13] IVYPORTAL-14419 Raise version of your portal maven artifacts to the next development cycle after release > Increase portal version by build param --- build/update-pom/Jenkinsfile | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/build/update-pom/Jenkinsfile b/build/update-pom/Jenkinsfile index f3684ebcdc..fd3dd068c2 100644 --- a/build/update-pom/Jenkinsfile +++ b/build/update-pom/Jenkinsfile @@ -73,14 +73,11 @@ def updateVersion() { maven cmd: "-f ${pomFile} versions:set-property versions:commit -Dproperty=build.plugin.version -DnewVersion=${params.buildPluginVersion}" } } - echo '============${params.portalVersion?.trim()} outside' if (!params.portalVersion?.trim().isEmpty()) { - echo '============ inside' sh '''#!/bin/bash update_xml() { - # Start Python scripts - need correct indentation - python3 - < Date: Fri, 27 Dec 2024 16:12:39 +0700 Subject: [PATCH 08/13] IVYPORTAL-14419 Raise version of your portal maven artifacts to the next development cycle after release > Increase portal version by build param --- build/update-pom/Jenkinsfile | 40 ++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/build/update-pom/Jenkinsfile b/build/update-pom/Jenkinsfile index fd3dd068c2..790d4f17ae 100644 --- a/build/update-pom/Jenkinsfile +++ b/build/update-pom/Jenkinsfile @@ -76,13 +76,13 @@ def updateVersion() { if (!params.portalVersion?.trim().isEmpty()) { sh '''#!/bin/bash - update_xml() { - python3 - < changes to tag , need removing namespace + root = stripNamespace(root) # By default, tags like are changed to tag , need removing namespace version = root.find("version") if version is not None: - version.text = portal_version + version.text = portalVersion dependencies = root.find("dependencies") if dependencies is not None: for dependency in dependencies.findall("dependency"): - group_id = dependency.find("groupId") - if group_id is not None and group_id.text in [ + groupId = dependency.find("groupId") + if groupId is not None and groupId.text in [ "com.axonivy.portal", ]: - version_tag = dependency.find("version") - if version_tag is not None: - version_tag.text = portal_version + versionTag = dependency.find("version") + if versionTag is not None: + versionTag.text = portalVersion # Write changes back to the file - tree.write(file_path, encoding="utf-8", xml_declaration=True) -EOF # End Python scripts - need correct indentation + tree.write(filePath, encoding="utf-8", xml_declaration=True) +except Exception as e: + print(f"Failed to process {filePath}: {e}", file=sys.stderr) +EOF } - file_patterns=( + filePatterns=( "AxonIvyPortal/*/pom.xml" "Showcase/*/pom.xml" "AxonIvyPortal/portal-selenium-test/customized_pom.xml" @@ -127,9 +127,9 @@ EOF # End Python scripts - need correct indentation "Documentation/public-api/pom.xml" ) - for pattern in "${file_patterns[@]}"; do + for pattern in "${filePatterns[@]}"; do for file in $pattern; do - update_xml "$file" + updatePortalVersion "$file" done done ''' From d9ad4962c2f901dbc01b383d3491f9935cd7d410 Mon Sep 17 00:00:00 2001 From: Tung Le Date: Fri, 27 Dec 2024 16:28:40 +0700 Subject: [PATCH 09/13] IVYPORTAL-14419 Raise version of your portal maven artifacts to the next development cycle after release > Increase portal version by build param --- build/update-pom/Jenkinsfile | 81 ++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 41 deletions(-) diff --git a/build/update-pom/Jenkinsfile b/build/update-pom/Jenkinsfile index 790d4f17ae..51fd259420 100644 --- a/build/update-pom/Jenkinsfile +++ b/build/update-pom/Jenkinsfile @@ -8,9 +8,9 @@ pipeline { } parameters { - string(name: 'buildPluginVersion', defaultValue: '13.1.0-SNAPSHOT', description: 'Axon Ivy build plugin version of all pom will be updated to.') - string(name: 'ivyEngineVersion', defaultValue: '13.1.0', description: 'Axon Ivy engine version of all pom will be updated to.') - string(name: 'portalVersion', defaultValue: '13.1.0', description: 'Portal version of all pom will be updated to.') + string(name: 'buildPluginVersion', defaultValue: '', description: 'Axon Ivy build plugin version of all pom will be updated to. If empty value, no changes.') + string(name: 'ivyEngineVersion', defaultValue: '', description: 'Axon Ivy engine version of all pom will be updated to. If empty value, no changes.') + string(name: 'portalVersion', defaultValue: '', description: 'Portal version of all pom will be updated to. If empty value, no changes.') string(name: 'branchToPush', defaultValue: 'portal-update-pom/master', description: 'Branch name to push changes. It must not be protected branches. After this build, create a pull request to merge to master') string(name: 'engineDownloadURL', defaultValue: '-Divy.engine.download.url=https://developer.axonivy.com/permalink/nightly/axonivy-engine.zip', description: '''Where to download engine? e.g. -Divy.engine.download.url=https://developer.axonivy.com/permalink/nightly/axonivy-engine.zip for nightly master @@ -23,43 +23,54 @@ pipeline { steps { script { currentBuild.description = "On ${env.NODE_NAME}" - docker.build('update-pom', '-f build/update-pom/Dockerfile .').inside('-v /var/tools/maven-cache:/home/build/') { - withEnv(['GIT_SSH_COMMAND=ssh -o StrictHostKeyChecking=no']) { - sshagent(credentials: ['github-axonivy']) { - sh """ - git remote set-url origin git@github.com:axonivy-market/portal.git - git checkout ${BRANCH_NAME} || git checkout -b ${BRANCH_NAME} - git pull origin ${BRANCH_NAME} - """ - echo '====================Update version====================' - updateVersion() - - echo '====================Commit to GIT====================' - changeLog = sh(returnStdout: true, script: 'git status -s').trim() - if (changeLog) { + if (!params.buildPluginVersion?.trim().isEmpty() || !params.ivyEngineVersion?.trim().isEmpty() + || !params.portalVersion?.trim().isEmpty()) { + docker.build('update-pom', '-f build/update-pom/Dockerfile .').inside('-v /var/tools/maven-cache:/home/build/') { + withEnv(['GIT_SSH_COMMAND=ssh -o StrictHostKeyChecking=no']) { + sshagent(credentials: ['github-axonivy']) { sh """ - git commit -a -m "Updated all pom build.plugin.version=${params.buildPluginVersion}, ivy.engine.version=${params.ivyEngineVersion}" - git checkout -b ${params.branchToPush} - git push origin -u ${params.branchToPush} + git remote set-url origin git@github.com:axonivy-market/portal.git + git checkout ${BRANCH_NAME} || git checkout -b ${BRANCH_NAME} + git pull origin ${BRANCH_NAME} """ - } else { - echo 'Nothing to commit.' + echo '====================Update version====================' + updateVersion() + + echo '====================Commit to GIT====================' + changeLog = sh(returnStdout: true, script: 'git status -s').trim() + if (changeLog) { + sh """ + git commit -a -m "Updated all pom build.plugin.version=${params.buildPluginVersion}, ivy.engine.version=${params.ivyEngineVersion}" + git checkout -b ${params.branchToPush} + git push origin -u ${params.branchToPush} + """ + } else { + echo 'Nothing to commit.' + } } } } } - // echo '====================Cache engine in local repository====================' - // removeCacheEngine() - // docker.build('fetch-cache', '-f build/Dockerfile .').inside('-v /var/tools/maven-cache:/home/build/') { - // maven cmd: 'clean install -f AxonIvyPortal/portal-components/pom.xml' - // } + echo '====================Cache engine in local repository====================' + removeCacheEngine() + docker.build('fetch-cache', '-f build/Dockerfile .').inside('-v /var/tools/maven-cache:/home/build/') { + maven cmd: 'clean install -f AxonIvyPortal/portal-components/pom.xml' + } } } } } } + +def removeCacheEngine() { + sh """ + cd /var/tools/maven-cache/.m2/repository/.cache/ivy + if [ -d ${params.ivyEngineVersion} ]; then rm -Rf ${params.ivyEngineVersion}; fi + """ +} + def updateVersion() { def pomFiles = ['AxonIvyPortal/portal-components/pom.xml', 'AxonIvyPortal/portal/pom.xml', 'AxonIvyPortal/portal-migration/pom.xml', 'AxonIvyPortal/portal-selenium-test/pom.xml', 'AxonIvyPortal/portal-selenium-test/customized_pom.xml', 'AxonIvyPortal/portal-selenium-test/document_screenshot_pom.xml', @@ -119,13 +130,8 @@ except Exception as e: EOF } - filePatterns=( - "AxonIvyPortal/*/pom.xml" - "Showcase/*/pom.xml" - "AxonIvyPortal/portal-selenium-test/customized_pom.xml" - "AxonIvyPortal/portal-selenium-test/document_screenshot_pom.xml" - "Documentation/public-api/pom.xml" - ) + filePatterns=("AxonIvyPortal/*/pom.xml" "Showcase/*/pom.xml" "AxonIvyPortal/portal-selenium-test/customized_pom.xml" + "AxonIvyPortal/portal-selenium-test/document_screenshot_pom.xml" "Documentation/public-api/pom.xml") for pattern in "${filePatterns[@]}"; do for file in $pattern; do @@ -135,10 +141,3 @@ EOF ''' } } - -def removeCacheEngine() { - sh """ - cd /var/tools/maven-cache/.m2/repository/.cache/ivy - if [ -d ${params.ivyEngineVersion} ]; then rm -Rf ${params.ivyEngineVersion}; fi - """ -} \ No newline at end of file From fcd85350e53cc232f4a106d0097c5057b0ede262 Mon Sep 17 00:00:00 2001 From: Tung Le Date: Fri, 27 Dec 2024 16:39:23 +0700 Subject: [PATCH 10/13] IVYPORTAL-14419 Raise version of your portal maven artifacts to the next development cycle after release > Increase portal version by build param --- build/update-pom/Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/update-pom/Jenkinsfile b/build/update-pom/Jenkinsfile index 51fd259420..95559a1d2b 100644 --- a/build/update-pom/Jenkinsfile +++ b/build/update-pom/Jenkinsfile @@ -8,7 +8,8 @@ pipeline { } parameters { - string(name: 'buildPluginVersion', defaultValue: '', description: 'Axon Ivy build plugin version of all pom will be updated to. If empty value, no changes.') + string(name: 'buildPluginVersion', defaultValue: '', description: '''Axon Ivy build plugin version of all pom will be updated to. If empty value, no changes. + If buildPluginVersion, ivyEngineVersion, portalVersion params all are empty, this build just updates cached engines, no GIT commits are created.''') string(name: 'ivyEngineVersion', defaultValue: '', description: 'Axon Ivy engine version of all pom will be updated to. If empty value, no changes.') string(name: 'portalVersion', defaultValue: '', description: 'Portal version of all pom will be updated to. If empty value, no changes.') string(name: 'branchToPush', defaultValue: 'portal-update-pom/master', description: 'Branch name to push changes. It must not be protected branches. After this build, create a pull request to merge to master') From 94aa7bd459f45717010bc6febb35981a805fffdc Mon Sep 17 00:00:00 2001 From: Tung Le Date: Fri, 27 Dec 2024 16:46:20 +0700 Subject: [PATCH 11/13] IVYPORTAL-14419 Raise version of your portal maven artifacts to the next development cycle after release > Increase portal version by build param --- build/update-pom/Jenkinsfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build/update-pom/Jenkinsfile b/build/update-pom/Jenkinsfile index 95559a1d2b..d4d417a33d 100644 --- a/build/update-pom/Jenkinsfile +++ b/build/update-pom/Jenkinsfile @@ -8,8 +8,7 @@ pipeline { } parameters { - string(name: 'buildPluginVersion', defaultValue: '', description: '''Axon Ivy build plugin version of all pom will be updated to. If empty value, no changes. - If buildPluginVersion, ivyEngineVersion, portalVersion params all are empty, this build just updates cached engines, no GIT commits are created.''') + string(name: 'buildPluginVersion', defaultValue: '', description: 'Axon Ivy build plugin version of all pom will be updated to. If empty value, no changes. If buildPluginVersion, ivyEngineVersion, portalVersion params all are empty, this build just updates cached engines, no GIT commits are created.') string(name: 'ivyEngineVersion', defaultValue: '', description: 'Axon Ivy engine version of all pom will be updated to. If empty value, no changes.') string(name: 'portalVersion', defaultValue: '', description: 'Portal version of all pom will be updated to. If empty value, no changes.') string(name: 'branchToPush', defaultValue: 'portal-update-pom/master', description: 'Branch name to push changes. It must not be protected branches. After this build, create a pull request to merge to master') From b9c53eb437cad73162534f3d40f2bfa41393c95d Mon Sep 17 00:00:00 2001 From: Tung Le Date: Mon, 30 Dec 2024 16:55:59 +0700 Subject: [PATCH 12/13] IVYPORTAL-14419 Raise version of your portal maven artifacts to the next development cycle after release > Update portal release build --- build/create-release/Jenkinsfile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/build/create-release/Jenkinsfile b/build/create-release/Jenkinsfile index e82ac1d08e..c439923256 100644 --- a/build/create-release/Jenkinsfile +++ b/build/create-release/Jenkinsfile @@ -69,6 +69,20 @@ pipeline { git tag -a ${params.releaseVersion} -m "Tagged Portal release ${params.releaseVersion} by build job ${env.BUILD_URL} git push origin ${params.releaseVersion} """ + + echo "====================Update Portal version for development after release ${params.releaseVersion} ====================" + def parts = releaseVersion.tokenize('.') + if (params.deployToRepo && parts[2].isNumber()) { + def nextVersion = "" + if ((parts[0] as int) % 2 == 0) { + nextVersion = "${parts[0]}.${parts[1]}.${(parts[2] as int) + 1}-SNAPSHOT" + } else { + nextVersion = "${parts[0]}.${(parts[1] as int) + 1}.0-SNAPSHOT" + } + build job: "portal-update-pom/${java.net.URLEncoder.encode(env.BRANCH_NAME, "UTF-8")}", + parameters: [string(name: 'portalVersion', value: "${nextVersion}")], + wait: true, propagate: false + } } } } From f53db63def45fa6e62e262dafee3d5c91a8def90 Mon Sep 17 00:00:00 2001 From: Tung Le Date: Mon, 30 Dec 2024 18:31:55 +0700 Subject: [PATCH 13/13] IVYPORTAL-14419 Raise version of your portal maven artifacts to the next development cycle after release > Update portal release build --- build/create-release/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/create-release/Jenkinsfile b/build/create-release/Jenkinsfile index c439923256..740f25361a 100644 --- a/build/create-release/Jenkinsfile +++ b/build/create-release/Jenkinsfile @@ -72,7 +72,7 @@ pipeline { echo "====================Update Portal version for development after release ${params.releaseVersion} ====================" def parts = releaseVersion.tokenize('.') - if (params.deployToRepo && parts[2].isNumber()) { + if (params.deployToRepo && parts.size() == 3 && parts[2].isNumber()) { def nextVersion = "" if ((parts[0] as int) % 2 == 0) { nextVersion = "${parts[0]}.${parts[1]}.${(parts[2] as int) + 1}-SNAPSHOT"