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

Add way to get locked resource name in pipeline

    XMLWordPrintable

Details

    Description

      https://issues.jenkins-ci.org/browse/JENKINS-34268 was closed implementing the possibility to lock a resources using a label in pipelines.
      But there is no syntax for knowing what the actually locked resource name is when using a pipeline and locking on a label.
      Specifically the proposed syntax from https://github.com/jenkinsci/lockable-resources-plugin/pull/36 : ", variable: 'MY_VAR'" is missing.

      Our use case is that we wan't to specify a label containing node names for legacy builders that can't run the slave.jar (java7) anymore. We want to lock a resource (host name) from the label and then ssh to that machine and execute some build steps. This works with the FreestyleJob functionality of "Reserved resources variable name".

      Solution

      It is now possible to access the locked resource via an configurable environment variable.

      lock(label: 'some_resource', variable: 'MY_VAR') {
        echo env.MY_VAR
      }
      

       

       

      Attachments

        Issue Links

          Activity

            fkykko Staffan Forsell created issue -
            f_julian Julian F. made changes -
            Field Original Value New Value
            Assignee Julian F. [ f_julian ]
            f_julian Julian F. made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            f_julian Julian F. made changes -
            Description https://issues.jenkins-ci.org/browse/JENKINS-34268 was closed implementing the possibility to lock a resources using a label in pipelines.
            But there is no syntax for knowing what the actually locked resource name is when using a pipeline and locking on a label.
            Specifically the proposed syntax from https://github.com/jenkinsci/lockable-resources-plugin/pull/36 : ", variable: 'MY_VAR'" is missing.

            Our use case is that we wan't to specify a label containing node names for legacy builders that can't run the slave.jar (java7) anymore. We wan't to lock a resource (host name) from the label and then ssh to that machine and execute some build steps. This works with the FreestyleJob functionality of "Reserved resources variable name".
            https://issues.jenkins-ci.org/browse/JENKINS-34268 was closed implementing the possibility to lock a resources using a label in pipelines.
             But there is no syntax for knowing what the actually locked resource name is when using a pipeline and locking on a label.
             Specifically the proposed syntax from [https://github.com/jenkinsci/lockable-resources-plugin/pull/36] : ", variable: 'MY_VAR'" is missing.

            Our use case is that we wan't to specify a label containing node names for legacy builders that can't run the slave.jar (java7) anymore. We wan't to lock a resource (host name) from the label and then ssh to that machine and execute some build steps. This works with the FreestyleJob functionality of "Reserved resources variable name".
            h4. Solution

            It is now possible to access the locked resource via an configurable environment variable.
            {code:java}
            lock(label: 'some_resource', variable: 'MY_VAR') {
              echo env.MY_VAR
            }
            {code}
             

             
            f_julian Julian F. made changes -
            Remote Link This issue links to " PR #50 (Web Link)" [ 15835 ]
            f_julian Julian F. made changes -
            Remote Link This issue links to "PR #49 (Web Link)" [ 20098 ]
            f_julian Julian F. made changes -
            Status In Progress [ 3 ] In Review [ 10005 ]
            f_julian Julian F. made changes -
            Resolution Fixed [ 1 ]
            Status In Review [ 10005 ] Resolved [ 5 ]
            jbogers Jeroen Bogers made changes -
            Link This issue is related to JENKINS-50176 [ JENKINS-50176 ]
            chrismaes Chris Maes made changes -
            Description https://issues.jenkins-ci.org/browse/JENKINS-34268 was closed implementing the possibility to lock a resources using a label in pipelines.
             But there is no syntax for knowing what the actually locked resource name is when using a pipeline and locking on a label.
             Specifically the proposed syntax from [https://github.com/jenkinsci/lockable-resources-plugin/pull/36] : ", variable: 'MY_VAR'" is missing.

            Our use case is that we wan't to specify a label containing node names for legacy builders that can't run the slave.jar (java7) anymore. We wan't to lock a resource (host name) from the label and then ssh to that machine and execute some build steps. This works with the FreestyleJob functionality of "Reserved resources variable name".
            h4. Solution

            It is now possible to access the locked resource via an configurable environment variable.
            {code:java}
            lock(label: 'some_resource', variable: 'MY_VAR') {
              echo env.MY_VAR
            }
            {code}
             

             
            https://issues.jenkins-ci.org/browse/JENKINS-34268 was closed implementing the possibility to lock a resources using a label in pipelines.
             But there is no syntax for knowing what the actually locked resource name is when using a pipeline and locking on a label.
             Specifically the proposed syntax from [https://github.com/jenkinsci/lockable-resources-plugin/pull/36] : ", variable: 'MY_VAR'" is missing.

            Our use case is that we wan't to specify a label containing node names for legacy builders that can't run the slave.jar (java7) anymore. We want to lock a resource (host name) from the label and then ssh to that machine and execute some build steps. This works with the FreestyleJob functionality of "Reserved resources variable name".
            h4. Solution

            It is now possible to access the locked resource via an configurable environment variable.
            {code:java}
            lock(label: 'some_resource', variable: 'MY_VAR') {
              echo env.MY_VAR
            }
            {code}
             

             

            People

              f_julian Julian F.
              fkykko Staffan Forsell
              Votes:
              24 Vote for this issue
              Watchers:
              27 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: