Milan
Milan

Reputation: 1760

Jenkins: disableConcurentBuild not working

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 ?

Upvotes: 3

Views: 1927

Answers (1)

Nicola Ben
Nicola Ben

Reputation: 11377

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

Upvotes: 3

Related Questions