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

Add workflow support for resource locking

    XMLWordPrintable

Details

    Description

      Add support to use this plugin from workflow to manage concurrent consumption of resources.

      Similar to how stage step works as blocked scoped to control concurrency of other builds for this job running this step at the same time, it would be useful to be able to do this for resources across jobs.

      Continue to allow the resources to be set up in the Jenkins configuration.

      Consumption of resources should be controlled with a syntax along these lines:

      For a single resource:

      resource (name: db-a-1, reservedVariable: DB_RESOURCE) {

      // Do something here that uses the resource

      echo “DB Resource(s) used = $DB_RESOURCE”
      }

      For a pool of resources sharing a label:

      resource (label: db-a, quantity: 2, reservedVariable: DB_RESOURCE) {

      // Do something here that uses the resource

      echo “DB Resource(s) used = $DB_RESOURCE”
      }

      Attachments

        Issue Links

          Activity

            Code changed in jenkins
            User: Antonio
            Path:
            pom.xml
            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/RequiredResourcesProperty.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/LockableResourcesQueueTaskDispatcher.java
            src/main/java/org/jenkins/plugins/lockableresources/queue/LockableResourcesStruct.java
            src/main/resources/org/jenkins/plugins/lockableresources/LockStep/config.jelly
            src/main/resources/org/jenkins/plugins/lockableresources/LockStep/help-inversePrecedence.html
            src/main/resources/org/jenkins/plugins/lockableresources/LockStep/help-resource.html
            src/test/java/org/jenkins/plugins/lockableresources/LockStepTest.java
            src/test/java/org/jenkins/plugins/lockableresources/LockableResourceTest.java
            http://jenkins-ci.org/commit/lockable-resources-plugin/466adef6c1b0212b2866f3b562a4059040a6109a
            Log:
            Merge pull request #25 from amuniz/JENKINS-30269

            JENKINS-30269 Add pipeline support for resource locking

            Compare: https://github.com/jenkinsci/lockable-resources-plugin/compare/76c93d5f4d1e...466adef6c1b0

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Antonio Path: pom.xml 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/RequiredResourcesProperty.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/LockableResourcesQueueTaskDispatcher.java src/main/java/org/jenkins/plugins/lockableresources/queue/LockableResourcesStruct.java src/main/resources/org/jenkins/plugins/lockableresources/LockStep/config.jelly src/main/resources/org/jenkins/plugins/lockableresources/LockStep/help-inversePrecedence.html src/main/resources/org/jenkins/plugins/lockableresources/LockStep/help-resource.html src/test/java/org/jenkins/plugins/lockableresources/LockStepTest.java src/test/java/org/jenkins/plugins/lockableresources/LockableResourceTest.java http://jenkins-ci.org/commit/lockable-resources-plugin/466adef6c1b0212b2866f3b562a4059040a6109a Log: Merge pull request #25 from amuniz/ JENKINS-30269 JENKINS-30269 Add pipeline support for resource locking Compare: https://github.com/jenkinsci/lockable-resources-plugin/compare/76c93d5f4d1e...466adef6c1b0

            Released as 1.8

            amuniz Antonio Muñiz added a comment - Released as 1.8
            aeon512 Florian Hug added a comment -

            First of all, it's great to finally have workflow support for resource locking.
            However, I couldn't find any possibility to lock, e.g. 3 resources assigned to the label Foo.
            As far as I have understood the documentation and from trying to understand the source code, the workflow support is limited to request a specific resource by name.

            Wouldn't it be great to have the full functionality available in workflows?
            Especially as these use cases were also mentioned by the issue reporter.

            aeon512 Florian Hug added a comment - First of all, it's great to finally have workflow support for resource locking. However, I couldn't find any possibility to lock, e.g. 3 resources assigned to the label Foo. As far as I have understood the documentation and from trying to understand the source code, the workflow support is limited to request a specific resource by name. Wouldn't it be great to have the full functionality available in workflows? Especially as these use cases were also mentioned by the issue reporter.

            As far as I have understood the documentation and from trying to understand the source code, the workflow support is limited to request a specific resource by name.

            Right.

            Wouldn't it be great to have the full functionality available in workflows?

            Especially as these use cases were also mentioned by the issue reporter.

            Yes. I've tried to cover the most common use-case in a Pipeline world (which is a replacement for stage concurrency: 1). The lock step has been designed to allow the addition of labels and multiple locking in future releases (filed as JENKINS-34268).

            amuniz Antonio Muñiz added a comment - As far as I have understood the documentation and from trying to understand the source code, the workflow support is limited to request a specific resource by name. Right. Wouldn't it be great to have the full functionality available in workflows? Especially as these use cases were also mentioned by the issue reporter. Yes. I've tried to cover the most common use-case in a Pipeline world (which is a replacement for stage concurrency: 1 ). The lock step has been designed to allow the addition of labels and multiple locking in future releases (filed as JENKINS-34268 ).

            Code changed in jenkins
            User: Jesse Glick
            Path:
            COMPATIBILITY.md
            http://jenkins-ci.org/commit/pipeline-plugin/7596ae10c2035a6c239e4ce8ca3af4c1ee1f78c8
            Log:
            Noting JENKINS-30269 (CC @amuniz)

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: COMPATIBILITY.md http://jenkins-ci.org/commit/pipeline-plugin/7596ae10c2035a6c239e4ce8ca3af4c1ee1f78c8 Log: Noting JENKINS-30269 (CC @amuniz)

            People

              amuniz Antonio Muñiz
              nharniman Nigel Harniman
              Votes:
              9 Vote for this issue
              Watchers:
              21 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: