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.


On Tuesday, July 26, 2016 at 7:49:21 PM UTC-4, Greg Smith wrote:
>
> 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
>
>
> On Thursday, May 12, 2016 at 4:23:50 PM UTC-4, David wrote:
>>
>> 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?
>> }
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/b8fdc1e5-6600-4ca3-b60f-edb3f00393f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to