3

I have a multibranch pipeline and I want to make sure it executes one run at a time. I cannot set a single executor on the agent since other jobs could run in other workspaces.

Here is how my pipeline is scripted:

/* Job properties */
properties([
    disableConcurrentBuilds(),
    gitLabConnection('Gitlab'),
    [$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: true],
    [$class: 'JobRestrictionProperty'],
    [$class: 'ThrottleJobProperty', categories: [], limitOneJobWithMatchingParams: false, maxConcurrentPerNode: 1, maxConcurrentTotal: 1, paramsToUseForLimit: '', throttleEnabled: true, throttleOption: 'project'],
    [$class: 'JobInclusionJobProperty', jobGroupName: 'UrgentJobs', useJobGroup: false]
])

node( allowedNodes ) {

    def hadBuildSucceeded = false

    ws(custom_directory) {  

       .....
    }
}

When I push three branches at a time, the job will start running three times at the same time, any suggestion on why this is failling ?

Milan
  • 1,547
  • 1
  • 24
  • 47

1 Answers1

3

If you need to push many different branches it will still build all of them, this option (disableConcurrentBuilds) will just limit each branch to one build at a time and will queue up jobs for any commits that get pushed after the initial job has been created.

It seems to be a bug (still unresolved, @april2018): https://issues.jenkins-ci.org/browse/JENKINS-35359

Nicola Ben
  • 10,615
  • 8
  • 41
  • 65
  • 3
    It's a pity the online doc isn't that clear about the limitation. A workaround is to use a dedicated plugin for locking a resource: https://wiki.jenkins.io/display/JENKINS/Lockable+Resources+Plugin – fduff Jan 30 '19 at 08:41