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

Feature/ivyportal 14419 raise version of your portal maven artifacts to the next development cycle after release #1353

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
f9f1347
IVYPORTAL-14419 Raise version of your portal maven artifacts to the n…
lttung-axonivy Dec 24, 2024
8d5c6a2
Merge branch 'master' of https://github.com/axonivy-market/portal int…
lttung-axonivy Dec 26, 2024
b57d67c
IVYPORTAL-14419 Raise version of your portal maven artifacts to the n…
lttung-axonivy Dec 26, 2024
3a8d22b
IVYPORTAL-14419 Raise version of your portal maven artifacts to the n…
lttung-axonivy Dec 26, 2024
f3665ed
IVYPORTAL-14419 Raise version of your portal maven artifacts to the n…
lttung-axonivy Dec 27, 2024
e17c4b6
IVYPORTAL-14419 Raise version of your portal maven artifacts to the n…
lttung-axonivy Dec 27, 2024
443e932
IVYPORTAL-14419 Raise version of your portal maven artifacts to the n…
lttung-axonivy Dec 27, 2024
4aeaa99
IVYPORTAL-14419 Raise version of your portal maven artifacts to the n…
lttung-axonivy Dec 27, 2024
ebcd635
IVYPORTAL-14419 Raise version of your portal maven artifacts to the n…
lttung-axonivy Dec 27, 2024
d9ad496
IVYPORTAL-14419 Raise version of your portal maven artifacts to the n…
lttung-axonivy Dec 27, 2024
fcd8535
IVYPORTAL-14419 Raise version of your portal maven artifacts to the n…
lttung-axonivy Dec 27, 2024
94aa7bd
IVYPORTAL-14419 Raise version of your portal maven artifacts to the n…
lttung-axonivy Dec 27, 2024
b9c53eb
IVYPORTAL-14419 Raise version of your portal maven artifacts to the n…
lttung-axonivy Dec 30, 2024
f53db63
IVYPORTAL-14419 Raise version of your portal maven artifacts to the n…
lttung-axonivy Dec 30, 2024
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
14 changes: 14 additions & 0 deletions build/create-release/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.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"
} 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
}
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions build/update-pom/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
127 changes: 96 additions & 31 deletions build/update-pom/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ 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: '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')
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
Expand All @@ -22,27 +23,30 @@ pipeline {
steps {
script {
currentBuild.description = "On ${env.NODE_NAME}"
docker.build('update-pom', '-f build/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 [email protected]: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 [email protected]: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.'
}
}
}
}
Expand All @@ -59,20 +63,81 @@ pipeline {
}
}


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',
'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}"
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}"
}
}
}

def removeCacheEngine() {
sh """
cd /var/tools/maven-cache/.m2/repository/.cache/ivy
if [ -d ${params.ivyEngineVersion} ]; then rm -Rf ${params.ivyEngineVersion}; fi
"""
}
if (!params.portalVersion?.trim().isEmpty()) {
sh '''#!/bin/bash
updatePortalVersion() {
python3 - <<EOF
import xml.etree.ElementTree as ET
from pathlib import Path
import sys

def stripNamespace(element):
# Iterate over all the elements and remove the namespace from the tag
for elem in element.iter():
# If the tag contains a namespace (indicated by '}')
if '}' in elem.tag:
elem.tag = elem.tag.split('}', 1)[1] # Keep only the part after '}'
return element

portalVersion = "$portalVersion"
filePath = "$1"

try:
tree = ET.parse(filePath)
root = tree.getroot()
root = stripNamespace(root) # By default, tags like <project> are changed to tag <ns0:project>, need removing namespace
version = root.find("version")
if version is not None:
version.text = portalVersion

dependencies = root.find("dependencies")
if dependencies is not None:
for dependency in dependencies.findall("dependency"):
groupId = dependency.find("groupId")
if groupId is not None and groupId.text in [
"com.axonivy.portal",
]:
versionTag = dependency.find("version")
if versionTag is not None:
versionTag.text = portalVersion

# Write changes back to the file
tree.write(filePath, encoding="utf-8", xml_declaration=True)
except Exception as e:
print(f"Failed to process {filePath}: {e}", file=sys.stderr)
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")

for pattern in "${filePatterns[@]}"; do
for file in $pattern; do
updatePortalVersion "$file"
done
done
'''
}
}
Loading