Hi,
I have 3 jobs:
1. Debug version (after commits).
2. QA version (manual, timer)
3. Release version (triggered by 2, manual).
Builds from second job should have BUILD_NUMBER larger by one than newest
build from first job, and when second job triggered third job then he
should have the same BUILD_NUMBER as second. When third job will be
triggered manual, then he also should have BUILD_NUMBER larger by one than
newest build from first job.
I hope that what I wrote is understandable ;P
I wrote script in groovy:
import jenkins.model.*
// Access to the Jenkins instance
jenkinsInstance = jenkins.model.Jenkins.instance
// Select jobs that match.
searchedJobName = "^synchronize_build_numbers.*"
jobName = "synchronize_build_numbers_qa"
allItems = jenkinsInstance.items
if ("${JOB_NAME}" == jobName) {
chosenJob = allItems.findAll{ job -> job.name.matches(
"synchronize_build_numbers_release") }
chosenJob.each{ job -> job.nextBuildNumber = "${BUILD_NUMBER}".toInteger
() }
} else {
chosenJobs = allItems.findAll{ job -> job.name.matches(searchedJobName)
}
buildNumber = chosenJobs.collect{ job -> job.nextBuildNumber }.max()
chosenJobs.each{ job -> job.nextBuildNumber = buildNumber }
}
return [:]
And it works, but I would like to make this script was more universal.
Thanks for help ;)
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/dc0e90d5-301f-4496-8325-a19632f4acea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.