Jenkins Multi-Pipeline Build Not Detecting Changes in Repository

David W. picture David W. · Sep 21, 2016 · Viewed 8.7k times · Source

We have a Subversion repository setup in this manor:

  • http://svn.vegicorp.net/svn/toast/api/trunk
  • http://svn.vegicorp.net/svn/toast/api/1.0
  • http://svn.vegicorp.net/svn/toast/data/trunk
  • http://svn.vegicorp.net/svn/toast/data/branches/1.2
  • http://svn.vegicorp.net/svn/toast/data/branches/1.3

I've setup a Jenkins Multi-Pipeline build for the entire toast project including all sub-projects -- each sub-project is a jarfile. What I want is for Jenkins to fire off a new build each time any file is changed in one of the toast projects. That project should rebuild. This way, if we create a new sub-project in toast or a new branch in one of the toast sub-projects, Jenkins will automatically create a new build for that.

Here's my Jenkins Multi-Branch setup:

Branch Sources

Subversion

  • Project Repository Base: http://svn.vegicorp.net/svn/toast
  • Credentials: builder/*****
  • Include Branches: */trunk, */branches/*
  • Exclude Branches: */private
  • Property Strategy: All branches get the same properties

Build Configuration

  • Mode: By Jenkinsfile

Build Triggers (None selected)

  • Trigger builds remotely (e.g., from scripts) Help for feature: Trigger * builds remotely (e.g., from scripts)
  • Build periodically Help for feature: Build periodically
  • Build when another project is promoted
  • Maven Dependency Update Trigger Help for feature: Maven Dependency Update Trigger
  • Periodically if not otherwise run

Note that the list of Build Triggers list does not include Poll SCM. Changes in the repository does not trigger any build. Jenkinsfiles are located at the root of each sub-project. If I force a reindex, all changed sub-projects get built and all new branches are found. I did originally checked Periodically and reindexed every minute to pick up a change, but that's klutzy and it seems to cause Jenkins to consume memory.

Triggering a build on an SCM change should be pretty basic, but I don't see a configuration parameter for this like I do with standard jobs. I also can't seem to go into sub-projects and set those to trigger builds either.

There must be something really, really simple that I am missing.

Configuration:

  • Jenkins 2.19
  • Pipeline 2.3
  • Pipeline API: 2.3
  • Pipeline Groovy: 2.17
  • Pipeline Job: 2.6
  • Pipeline REST API Plugin: 2.0
  • Pipeline Shared Groovy Libraries: 2.3
  • Pipeline: Stage View Plugin: 1.7
  • Pipeline: Supporting APIs 2.2
  • SCM API Plugin: 1.2

Answer

David W. picture David W. · Sep 30, 2016

I finally found the answer. I found a entry in the Jenkins' Jira Database that mentioned this exact issue. The issue is called SCM polling is not being performed in multibranch pipeline with Mercurial SCM. Other users chimed in too.

The answer was that Jenkins Multi-branch projects don't need to poll the SCM because indexing the branches does that for you:

Branch projects (the children) do not poll in isolation. Rather, the multibranch project (the parent folder) subsumes that function as part of branch indexing. If there are new heads on existing branches, new branch project builds will be triggered. You need merely check the box Periodically if not otherwise run in the folder configuration.

So, I need to setup reindexing of the branches. I'm not happy with this solution because it seems rather clumsy. I can add post-commit and post-push hooks in SVN and Git to trigger builds when a change takes place, and then reindex on a periodic basis (say once per hour). The problem means configuring these hooks and then keeping them up to date. Each project needs its own POST action which means updating the repository server every time a project changes. With polling, I didn't have to worry about hook maintenance.