Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-34273

Extend quantity configuration to Pipeline lock step

      Extend the use of quantity configuration parameter to the lock step.

      The behavior should be the same than defined for freestyle builds.

      The DSL should look like this:

      lock (resource: 'RAM', quantity: 3) { ... }
      

      quantity must be applicable to any of resource, resources or label (see JENKINS-34268).

          [JENKINS-34273] Extend quantity configuration to Pipeline lock step

          Florian Hug added a comment -

          This functionality has been implemented (together with the label functionality of JENKINS-34268) in PR26. Since this is my first Jenkins plugin contribution (and my first actual Java implementation) I'm open for any kind of feedback.

          lock(label: "MyLabelName", quantity: 3) {
              // body
          }
          

          Florian Hug added a comment - This functionality has been implemented (together with the label functionality of JENKINS-34268 ) in PR26 . Since this is my first Jenkins plugin contribution (and my first actual Java implementation) I'm open for any kind of feedback. lock(label: "MyLabelName" , quantity: 3) { // body }

          Epsilon B added a comment -

          Confirmed working in PR26
          Merged also in PR36

          Epsilon B added a comment - Confirmed working in PR26 Merged also in PR36

          Code changed in jenkins
          User: Antonio Muniz
          Path:
          src/main/java/org/jenkins/plugins/lockableresources/BackwardCompatibility.java
          src/main/java/org/jenkins/plugins/lockableresources/LockStep.java
          src/main/java/org/jenkins/plugins/lockableresources/LockStepExecution.java
          src/main/java/org/jenkins/plugins/lockableresources/LockableResource.java
          src/main/java/org/jenkins/plugins/lockableresources/LockableResourcesManager.java
          src/main/java/org/jenkins/plugins/lockableresources/actions/LockableResourcesRootAction.java
          src/main/java/org/jenkins/plugins/lockableresources/queue/LockRunListener.java
          src/main/java/org/jenkins/plugins/lockableresources/queue/LockableResourcesStruct.java
          src/main/java/org/jenkins/plugins/lockableresources/queue/QueuedContextStruct.java
          src/main/resources/org/jenkins/plugins/lockableresources/LockStep/config.jelly
          src/main/resources/org/jenkins/plugins/lockableresources/LockStep/help-label.html
          src/main/resources/org/jenkins/plugins/lockableresources/LockStep/help-quantity.html
          src/main/resources/org/jenkins/plugins/lockableresources/LockStep/help-resource.html
          src/test/java/org/jenkins/plugins/lockableresources/LockStepTest.java
          http://jenkins-ci.org/commit/lockable-resources-plugin/974572db98214f7b9293a303c9fd8371877250a0
          Log:
          Merge pull request #42 from amuniz/pr-26-fix

          JENKINS-34268JENKINS-34273 Lock multiple resources with specific quantity

          Compare: https://github.com/jenkinsci/lockable-resources-plugin/compare/ba48550fa5bc...974572db9821

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Antonio Muniz Path: src/main/java/org/jenkins/plugins/lockableresources/BackwardCompatibility.java src/main/java/org/jenkins/plugins/lockableresources/LockStep.java src/main/java/org/jenkins/plugins/lockableresources/LockStepExecution.java src/main/java/org/jenkins/plugins/lockableresources/LockableResource.java src/main/java/org/jenkins/plugins/lockableresources/LockableResourcesManager.java src/main/java/org/jenkins/plugins/lockableresources/actions/LockableResourcesRootAction.java src/main/java/org/jenkins/plugins/lockableresources/queue/LockRunListener.java src/main/java/org/jenkins/plugins/lockableresources/queue/LockableResourcesStruct.java src/main/java/org/jenkins/plugins/lockableresources/queue/QueuedContextStruct.java src/main/resources/org/jenkins/plugins/lockableresources/LockStep/config.jelly src/main/resources/org/jenkins/plugins/lockableresources/LockStep/help-label.html src/main/resources/org/jenkins/plugins/lockableresources/LockStep/help-quantity.html src/main/resources/org/jenkins/plugins/lockableresources/LockStep/help-resource.html src/test/java/org/jenkins/plugins/lockableresources/LockStepTest.java http://jenkins-ci.org/commit/lockable-resources-plugin/974572db98214f7b9293a303c9fd8371877250a0 Log: Merge pull request #42 from amuniz/pr-26-fix JENKINS-34268 JENKINS-34273 Lock multiple resources with specific quantity Compare: https://github.com/jenkinsci/lockable-resources-plugin/compare/ba48550fa5bc...974572db9821

          Released as 1.11

          Antonio Muñiz added a comment - Released as 1.11

          Sorin Sbarnea added a comment - - edited

          Thanks for fixing this. I observed that currently there is no way to configure the quantity of specific resource and we are forced to add lots of duplicated resources in order to overcome this. Still this does not scale and after 5-10 clones it becomes too hard to add additional. Due to this I raised JENKINS-42339 for adding a quantity inside the configure screen.

          Sorin Sbarnea added a comment - - edited Thanks for fixing this. I observed that currently there is no way to configure the quantity of specific resource and we are forced to add lots of duplicated resources in order to overcome this. Still this does not scale and after 5-10 clones it becomes too hard to add additional. Due to this I raised JENKINS-42339 for adding a quantity inside the configure screen.

          m corbion added a comment - - edited

          We are also looking for something like ssbarnea. We have a system running automation where we need to reserve resources dynamically some of them being clients and other being servers. Having the lock in a single step is highly important for us, however we don't always have the same number of servers as we have clients. We tried a workaround by creating a list of label or a chain of string  ['CLIENT', 'CLIENT', 'CLIENT', 'SERVER'] hoping that this can help us circumvent the problem but that's not how the plugin seems to work.

          m corbion added a comment - - edited We are also looking for something like ssbarnea . We have a system running automation where we need to reserve resources dynamically some of them being clients and other being servers. Having the lock in a single step is highly important for us, however we don't always have the same number of servers as we have clients. We tried a workaround by creating a list of label or a chain of string  ['CLIENT', 'CLIENT', 'CLIENT', 'SERVER'] hoping that this can help us circumvent the problem but that's not how the plugin seems to work.

          t stibbs added a comment -

          Am I the only person who's ended up looking at this ticket to try and work out what the 'quantity' flag actually does? If I have a lockable resource called 'abc' and I say lock (resource: 'abc', quantity: 3), what does that actually do? I expected to somewhere set the maximum number of things available to lock within 'abc' and then the pipeline scripts could acquire 3 of them, but I don't see how to set the max. So it acquires 3, out of...?

          t stibbs added a comment - Am I the only person who's ended up looking at this ticket to try and work out what the 'quantity' flag actually does? If I have a lockable resource called 'abc' and I say  lock (resource: 'abc', quantity: 3) , what does that actually do? I expected to somewhere set the maximum number of things available to lock within 'abc' and then the pipeline scripts could acquire 3 of them, but I don't see how to set the max. So it acquires 3, out of...?

          tstibbs Did you figure out how to set the maximum? I'm facing the same lack of documentation as you.

          Robin Björklin added a comment - tstibbs Did you figure out how to set the maximum? I'm facing the same lack of documentation as you.

          Janos Feher added a comment - - edited

          rbjorklin, tstibbs: you need to copy the instance multiple times and group them by label. So you create

          • resource1, label: my_resource
          • resource2, label: my_resource
          • resource3, label: my_resource
          • resource4, label: my_resource
          • resource5, label: my_resource

          Now you have my_resource with a quantity of 5.

          Janos Feher added a comment - - edited rbjorklin , tstibbs : you need to copy the instance multiple times and group them by label. So you create resource1, label: my_resource resource2, label: my_resource resource3, label: my_resource resource4, label: my_resource resource5, label: my_resource Now you have my_resource with a quantity of 5.

            amuniz Antonio Muñiz
            amuniz Antonio Muñiz
            Votes:
            7 Vote for this issue
            Watchers:
            17 Start watching this issue

              Created:
              Updated:
              Resolved: