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

Lockable resource notes read and update pipeline step

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • Jenkins 2.341

      Is it possible to edit notes for lockable resource by it label in scripted or declarative pipeline?
      feature for reading notes will by nice too.

      if this feature already exist please add it to plugin readme

          [JENKINS-68225] Lockable resource notes read and update pipeline step

          The Lockable Resources plugin does not provide a pipeline step for reading or modifying the notes of lockable resources, but I suppose a global pipeline library would be trusted by Jenkins and would be able to call org.jenkins.plugins.lockableresources.LockableResourcesManager.get() (source, javadoc), navigate to the LockableResource instance from there, and call LockableResource.getNote() or LockableResource.setNote(String note).

          Kalle Niemitalo added a comment - The Lockable Resources plugin does not provide a pipeline step for reading or modifying the notes of lockable resources, but I suppose a global pipeline library would be trusted by Jenkins and would be able to call org.jenkins.plugins.lockableresources.LockableResourcesManager.get() ( source , javadoc ), navigate to the LockableResource instance from there, and call LockableResource.getNote() or LockableResource.setNote(String note).

          Viktor Sam added a comment -

          You mean:

          def rManager = org.jenkins.plugins.lockableresources.LockableResourcesManager
          def MyRManager = rManager.get()
          def myResources = MyRManager.getResources() 
          def resource = myResource.each{ r ->
             println r.getName()
             println r.getNote()
          .... etc.....
          }  

           4 script approve needed, and looks dirty, but it works

          Viktor Sam added a comment - You mean: def rManager = org.jenkins.plugins.lockableresources.LockableResourcesManager def MyRManager = rManager.get() def myResources = MyRManager.getResources() def resource = myResource.each{ r -> println r.getName() println r.getNote() .... etc..... }    4 script approve needed, and looks dirty, but it works

          What kind of information do you intend to save in the notes?

          I can imagine storing things like:

          • Database connection settings, if you have a pool of databases that can be used for testing. (Machine-readable, changing rarely, describing the resource)
          • Whether the previous use of the resource was cleaned up properly; if not, then the next use needs to reinitialize the resource somehow. (Machine-readable, changing frequently, describing the resource)
          • A description of what the build is currently doing with the resource, to be read by Jenkins users. (Human-readable, changing frequently, describing the lock)
          • History of recent uses of the resource over multiple builds. (Human-readable, changing frequently, describing the resource)

          Kalle Niemitalo added a comment - What kind of information do you intend to save in the notes? human-readable or machine-readable changing frequently or rarely describing the resource or describing the lock; this would matter for Resource should have a quantity · Issue #128 · jenkinsci/lockable-resources-plugin I can imagine storing things like: Database connection settings, if you have a pool of databases that can be used for testing. (Machine-readable, changing rarely, describing the resource) Whether the previous use of the resource was cleaned up properly; if not, then the next use needs to reinitialize the resource somehow. (Machine-readable, changing frequently, describing the resource) A description of what the build is currently doing with the resource, to be read by Jenkins users. (Human-readable, changing frequently, describing the lock) History of recent uses of the resource over multiple builds. (Human-readable, changing frequently, describing the resource)

          Viktor Sam added a comment -

          In my case resource is statefull enviroment(jenkins agents on vm) with random set of services. Dev or test team member configure service set with parametrs and locks resource by userid.
          Now notes are sets manually which do it are only human readable. Locked resource already has userid, so i need lock time(declarative pipeline not set time properly ), service set , service version, Jira issue link, user comments, last build status. 
          I haven't 'append' case at now, but any way it will be - get html note - parse - edit - replace note. 
          When lockable resource didn't have no notes feature, i have pritty same idea - integrate confluence space  via api. But there some ssl issue on confluence side which cant be solved now

          Viktor Sam added a comment - In my case resource is statefull enviroment(jenkins agents on vm) with random set of services. Dev or test team member configure service set with parametrs and locks resource by userid. Now notes are sets manually which do it are only human readable. Locked resource already has userid, so i need lock time(declarative pipeline not set time properly ), service set , service version, Jira issue link, user comments, last build status.  I haven't 'append' case at now, but any way it will be - get html note - parse - edit - replace note.  When lockable resource didn't have no notes feature, i have pritty same idea - integrate confluence space  via api. But there some ssl issue on confluence side which cant be solved now

          I have created similar feature request yesterday

          https://github.com/jenkinsci/lockable-resources-plugin/issues/426

          I will link this issue there and I will try to provide more flexible way to access locked resource in scope

           

          something like this

          ```

          lock('ABC')

          { it ->   it.setNote('call me when you trust') }

          ```

          ```

          lock(label : 'ABC', quantity : 2)

          { it1, it2 ->   it1.setNote('note 1')   it2.setNote('note 2') }

          ```

          Martin Pokorny added a comment - I have created similar feature request yesterday https://github.com/jenkinsci/lockable-resources-plugin/issues/426 I will link this issue there and I will try to provide more flexible way to access locked resource in scope   something like this ``` lock('ABC') { it ->   it.setNote('call me when you trust') } ``` ``` lock(label : 'ABC', quantity : 2) { it1, it2 ->   it1.setNote('note 1')   it2.setNote('note 2') } ```

            Unassigned Unassigned
            sam117 Viktor Sam
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: