30. ledna 2016

Jenkins workflowpipeline-multibranch

Jenkins workflowpipeline-multibranch seems to be great approach for creating and managing build per branch. In situation when you have a project with tens of branches in repository and you need to build any of them it's not easy to manage it. It's not unusual that some branches requires different steps/environment for build. Few options how to handle it are listed bellow.

Generic job for all branches:

  • Pros
    • One single job you have to care about
    • Easy to create, as branch selector is *
  • Gotchas
    • Mixed change log for all branches
    • Some branches might require special handling and generic script does not support it -> complicated job script, change of job script might brake another branch
    • In most cases job script is not versioned with project, complicates build of older revisions

Branch specific jobs:
  • Pros
    • Every branch can use its specific build script
    • Readable change log, separate for each branch
  • Gotchas
    • Creation & management is time consuming (even with scripts around)
    • In most cases job script is not versioned with project, complicates build of older revisions

  • Pros
    • Scans repository for branches and creates job for each branch with Jenkinsfile in repository root
    • Script file is part of project repository, versioned with code, so when you need to build older version all you have to do is checkout older version source code
  • Gotchas
    • Jenkinsfile is required on Jenkins master before jobs starts, so every branch has it's own repository replica on Jenkins master (disk consuming for big repos with lot of branches!)
    • Due to repository replica on jenkins master, you have to pull changes twice. First time for master (to get current Jenkinsfile), second time on slave (if any) to work on top of source code.
I would like to go with pipeline-multibranch approach, but storage costs a pretty penny. So I'm looking for good mix of Pros/Gotchas for new build environment where one of git (~800MiB) repos contains 100+ active branches (=> 80GiB storage required just for pipeline-multibranch), where we need to have different build scripts for them. And even worse for each branch we need to build for 5+ targets and two different configurations (this nicely fits to parallel in pipeline/or multi configuration build).

I cannot find any example of more complicated pipeline/Jenkinsfile, but will be glad to see one.