Skip to content

Bug-Jenkinsfile Make Jenkinsfile to be more generic whatever the branch and version of Silverpeas #858

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

Merged
merged 1 commit into from
Jul 19, 2024
Merged
Changes from all commits
Commits
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
52 changes: 38 additions & 14 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,10 @@ pipeline {
steps {
script {
println "Current branch is ${env.BRANCH_NAME}"
switch (env.BRANCH_NAME) {
case 'master':
silverpeasCore = 'Master'
break
case env.STABLE_BRANCH:
silverpeasCore = 'Stable'
break
default:
silverpeasCore = env.BRANCH_NAME
break
}
version = computeSnapshotVersion()
println "Actual stable branch is ${env.STABLE_BRANCH}"
def pom = readMavenPom()
silverpeasCore = getSilverpeasCoreProject(pom)
version = computeSnapshotVersion(pom)
lockFilePath = createLockFile(version, 'components')
waitForDependencyRunningBuildIfAny(version, 'core')
}
Expand Down Expand Up @@ -109,8 +101,7 @@ pipeline {
}
}

def computeSnapshotVersion() {
def pom = readMavenPom()
def computeSnapshotVersion(pom) {
final String version = pom.version
final String defaultVersion = env.BRANCH_NAME == 'master' ? version :
env.BRANCH_NAME.toLowerCase().replaceAll('[# -]', '')
Expand Down Expand Up @@ -187,4 +178,37 @@ def checkParentPOMVersion(version) {
mvn versions:update-parent -DgenerateBackupPoms=false -DparentVersion="[${parentVersion}]"
"""
}
}

def getSilverpeasCoreProject(pom) {
String silverpeasCoreProject
switch (env.BRANCH_NAME) {
case 'master':
silverpeasCoreProject = 'Master'
break
case env.STABLE_BRANCH:
silverpeasCoreProject = 'Stable'
break
default:
Matcher branchMatcher = env.BRANCH_NAME =~ /\d+.\d+.x/
if (branchMatcher.matches()) {
// an old stable project
silverpeasCoreProject = env.BRANCH_NAME
} else {
// this is a PR
String version = pom.version
Matcher versionMatcher = version =~ /\d+.\d+.\d+-SNAPSHOT/
if (versionMatcher.matches()) {
if (version.startsWith(env.STABLE_BRANCH.replace('.x', ''))) {
silverpeasCoreProject = 'Stable'
} else {
silverpeasCoreProject = version.replaceFirst('.\\d+-SNAPSHOT', '.x')
}
} else {
silverpeasCoreProject = 'Master'
}
}
break
}
return silverpeasCoreProject
}