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

Lockable resources: Allow to define time constrained resources

      Sometimes a resource is limited or unavailable only during certain times, for example because of a fixed maintenance window for a specific service. It would therefor be nice to be able to optionally define a time frame during which the lock must be aquired. Outside that time frame, the resource should always be considered available.

          [JENKINS-63141] Lockable resources: Allow to define time constrained resources

          OK, found a workaround by using a blocking job that runs (and acquires the lock) as long as the resource is unavailable and a Groovy expression in the jobs that need the resource which only tries to acquire the lock at certain time.

          However, I need to implement this using JobDSL, but the documentation doesn't say anything about how to add a Groovy expression with JobDSL. Can you please clarify?

          Dirk Heinrichs added a comment - OK, found a workaround by using a blocking job that runs (and acquires the lock) as long as the resource is unavailable and a Groovy expression in the jobs that need the resource which only tries to acquire the lock at certain time. However, I need to implement this using JobDSL, but the documentation doesn't say anything about how to add a Groovy expression with JobDSL. Can you please clarify?

          Could configure it using the following JobDSL snippet:

          job('LockableTest') {
            def lockScript = '...'
            configure { project ->
              project / 'properties' / 'org.jenkins.plugins.lockableresources.RequiredResourcesProperty' {
                'resourceMatchScript' {
                  'script'(lockScript)
                  'sandbox'(false)
                }
              }
            }
          }

          However, as this is quite cumbersome, it would be really great to have direct support for Groovy expressions in JobDSL.

          Dirk Heinrichs added a comment - Could configure it using the following JobDSL snippet: job( 'LockableTest' ) { def lockScript = '...' configure { project -> project / 'properties' / 'org.jenkins.plugins.lockableresources.RequiredResourcesProperty' { 'resourceMatchScript' { 'script' (lockScript) 'sandbox' ( false ) } } } } However, as this is quite cumbersome, it would be really great to have direct support for Groovy expressions in JobDSL.

            Unassigned Unassigned
            dhs Dirk Heinrichs
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: