|
||||||||
|
This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators. For more information on JIRA, see: http://www.atlassian.com/software/jira |
||||||||
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

An example might be useful.
Currently I have around 50 projects in our internal github, most are using git-flow for managing releases and features. That means that I have two core jobs for branches (develop and master) that change rather infrequently.
For each project there are a number of short-lived branches for features, releases and hotfixes (branch names: feature/, release/, hotfix/*) where I would like to check and (re-)create Jobs for each branch more frequently than for the main ones.
So here is my current solution (the important parts):
repositories.each { repo -> /* get branches from github */branches.each { def branchName = it.name switch (branchName) { case productionBranchName: case developmentBranchName: job { /* define a job for each master(production) and develop (development) branch } break default: /* skip other branches now */ break } } /* generate monitor job per repository */ job { triggers { cron 'H/5 * * * *' } steps { dsl { removeAction('DELETE') //text readFileFromWorkspace('templates.monitor-job.groovy') text """/* Job for monitoring feature/release and other branches. Generated code, DO NOT EDIT!! */ /* iterae over branches */ branches.each { def branchName = it.name /* Skip all non-feature/release/hotfix branches */ if (branchName =~ /(feature|release|hotfix)\\/.+/) { job { name "${baseJobName}-\${branchName.replaceAll('/', '-')}" /* use develop job as template */ using "${baseJobName}-${developmentBranchName}" scm { github(ghproject, "origin/\${branchName}", 'ssh', 'source.xing.com') } } } } """ } } } }Basically I install the two main jobs that only change when I update the initial DSL specification. The monitor job runs on a rather frequent cron schedule to catch all short-lived branches and creates jobs for feature branches based on the current development-Branch job definition.
As the DSL keeps track both of the generated jobs and of the templates that have been used for jobs I get an automatic cascade that updates my feature branches whenever I roll out changes to the development branch. And jobs for feature branches that no longer exist get deleted automatically.
Integrating the DSL definition as String enables to generate a customized job template for each repository (necessary as there is a different template job for each repository)