File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#! 'groovy'
2+ import groovy.transform.Field
23
3- def projectName = env. JOB_NAME . substring(0 , env. JOB_NAME . indexOf(" /" )) // depends on name and location of multibranch pipeline in jenkins
4+ @Field
5+ String projectNamePattern = " ^exedio/([a-z]*)/.*" // depends on location of multibranch pipeline in jenkins
46def jdk = ' openjdk-17'
57def idea = ' 2021.2'
68def ideaSHA256 = ' 7c27799861fb1ba0d43a3565a1ec2be789e1871191be709f0e79f1e17d3571fe'
142144
143145 parallelBranches[" Ivy" ] =
144146 {
145- def cache = ' jenkins-build-survivor-' + projectName + " -Ivy"
147+ def cache = ' jenkins-build-survivor-' + projectName() + " -Ivy"
146148 // noinspection GroovyAssignabilityCheck
147149 lockNodeCheckoutAndDelete(cache)
148150 {
@@ -190,6 +192,22 @@ finally
190192 updateGitlabCommitStatus state : currentBuild. resultIsBetterOrEqualTo(" SUCCESS" ) ? " success" : " failed" // https://docs.gitlab.com/ee/api/commits.html#post-the-build-status-to-a-commit
191193}
192194
195+ // ------------------- LIBRARY ----------------------------
196+ // The code below is meant to be equal across all projects.
197+
198+ String projectName ()
199+ {
200+ String jobName = env. JOB_NAME
201+ java.util.regex.Matcher m = java.util.regex.Pattern . compile(projectNamePattern).
202+ matcher(jobName)
203+ if (! m. matches())
204+ error " illegal jobName >" + jobName + " <, must match " + projectNamePattern
205+
206+ String result = m. group(1 )
207+ echo(" project name >" + result + " < computed from >" + jobName + " <" )
208+ return result
209+ }
210+
193211def lockNodeCheckoutAndDelete (resource , Closure body )
194212{
195213 lock(resource)
You can’t perform that action at this time.
0 commit comments