Is `concurrency: 1` on a stage in multibranch pipeline build supposed to apply to all branches for that build?

1,520 views
Skip to first unread message

David

unread,
May 12, 2016, 4:23:50 PM5/12/16
to Jenkins Users
I have a Jenkinsfile in my repo, and one of the stages uses resources shared across every branch, but I need to limit it to only one build at a time. It seems that if two branches are being built simultaneously, they don't respect the concurrency parameter and end up using the shared resource at the same time.

I'd like the branch builds to wait until the other branch is out of that shared stage before entering, which is what i thought the concurrency parameter would do.

stage name: 'Source code checkout'
node
{
    checkout scm
}

// Tests reuse the same resources
// I thought setting concurrency to 1 would avoid multiple branch builds stepping on each other
stage name
: 'Test', concurrency: 1
node
{
   
// This doesn't seem to be limited to one branch build at a time
   
// How can I achieve that?
}



Greg Smith

unread,
Jul 26, 2016, 7:49:21 PM7/26/16
to Jenkins Users
Hi David,

Did you ever find a nice solution to this problem?  I would also like to lock builds for projects with multiple branches / PRs, but don't want to mess with using lockable resources (which seems to be the only solution right now that works with pipeline code, but it requires you define a resource for each project)

Cheers,
Greg

David

unread,
Jul 26, 2016, 9:15:57 PM7/26/16
to Jenkins Users
I never found a good solution, but I am using the lockable resources plugin (https://wiki.jenkins-ci.org/display/JENKINS/Lockable+Resources+Plugin). I didn't need to define each resource manually:

When the lock step is used in a Pipeline, if the resource to be locked isn't already defined in the Jenkins global configuration, it'll be set up automatically.

Greg Smith

unread,
Jul 29, 2016, 3:26:00 PM7/29/16
to Jenkins Users

Was watching the new release notes for some plugins, and happened to find this:

JENKINS-34547 Converted concurrency setting to a job property, allowing it to be defined in a multibranch Jenkinsfile via the properties step.

It looks like it is now possible to set concurrency so that it does go across all branches -- though I'm not sure how to use it yet, seems very promising.

Cheers,
Greg
Reply all
Reply to author
Forward
0 new messages