Skip to content

Commit b360068

Browse files
committed
Modify Jenkinsfile to take into account the Silverpeas Core project
matching the current Silverpeas Components according to the actual SCM branch
1 parent ad3426c commit b360068

File tree

1 file changed

+42
-7
lines changed

1 file changed

+42
-7
lines changed

Jenkinsfile

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ pipeline {
44
environment {
55
lockFilePath = null
66
version = null
7-
silverpeas = 'Master'
7+
silverpeas = null
88
}
99
agent {
1010
docker {
11-
image 'silverpeas/silverbuild'
11+
image 'silverpeas/silverbuild:6.4'
1212
args '''
1313
-v $HOME/.m2:/home/silverbuild/.m2
1414
-v $HOME/.gitconfig:/home/silverbuild/.gitconfig
@@ -21,7 +21,10 @@ pipeline {
2121
stage('Waiting for core running build if any') {
2222
steps {
2323
script {
24-
version = computeSnapshotVersion()
24+
println "Current branch is ${env.BRANCH_NAME}"
25+
def pom = readMavenPom()
26+
silverpeasCore = getSilverpeasCoreProject(pom)
27+
version = computeSnapshotVersion(pom)
2528
lockFilePath = createLockFile(version, 'looks')
2629
waitForDependencyRunningBuildIfAny(version, 'core')
2730
}
@@ -83,7 +86,7 @@ pipeline {
8386
-Dsonar.pullrequest.base=master \\
8487
-Dsonar.pullrequest.provider=github \\
8588
-Dsonar.host.url=${SONAR_HOST_URL} \\
86-
-Dsonar.login=${SONAR_AUTH_TOKEN} \\
89+
-Dsonar.token=${SONAR_AUTH_TOKEN} \\
8790
-Dsonar.scanner.force-deprecated-java-version=true
8891
"""
8992
}
@@ -103,14 +106,13 @@ pipeline {
103106
deleteLockFile(lockFilePath)
104107
step([$class : 'Mailer',
105108
notifyEveryUnstableBuild: true,
106-
recipients : "miguel.moquillon@silverpeas.org, yohann.chastagnier@silverpeas.org, nicolas.eysseric@silverpeas.org",
109+
recipients : "miguel.moquillon@silverpeas.org, david.lesimple@silverpeas.org, silveryocha@chastagnier.com",
107110
sendToIndividuals : true])
108111
}
109112
}
110113
}
111114

112-
def computeSnapshotVersion() {
113-
def pom = readMavenPom()
115+
def computeSnapshotVersion(pom) {
114116
final String version = pom.version
115117
final String defaultVersion = env.BRANCH_NAME == 'master' ? version :
116118
env.BRANCH_NAME.toLowerCase().replaceAll('[# -]', '')
@@ -187,3 +189,36 @@ def checkParentPOMVersion(version) {
187189
"""
188190
}
189191
}
192+
193+
def getSilverpeasCoreProject(pom) {
194+
String silverpeasCoreProject
195+
switch (env.BRANCH_NAME) {
196+
case 'master':
197+
silverpeasCoreProject = 'Master'
198+
break
199+
case env.STABLE_BRANCH:
200+
silverpeasCoreProject = 'Stable'
201+
break
202+
default:
203+
Matcher branchMatcher = env.BRANCH_NAME =~ /\d+.\d+.x/
204+
if (branchMatcher.matches()) {
205+
// an old stable project
206+
silverpeasCoreProject = env.BRANCH_NAME
207+
} else {
208+
// this is a PR
209+
String version = pom.version
210+
Matcher versionMatcher = version =~ /\d+.\d+.\d+-SNAPSHOT/
211+
if (versionMatcher.matches()) {
212+
if (version.startsWith(env.STABLE_BRANCH.replace('.x', ''))) {
213+
silverpeasCoreProject = 'Stable'
214+
} else {
215+
silverpeasCoreProject = version.replaceFirst('.\\d+-SNAPSHOT', '.x')
216+
}
217+
} else {
218+
silverpeasCoreProject = 'Master'
219+
}
220+
}
221+
break
222+
}
223+
return silverpeasCoreProject
224+
}

0 commit comments

Comments
 (0)