Stage locks are created for skipped stages in declarative pipeline

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

    Given the following declarative pipeline:

    pipeline {
      stages {
        stage('Example stage') {
          when { expression { false } }
          options { lock resource: 'example resource' }
          steps { // ... }
        }
      }
    }
    

    Even though 'example stage' is skipped due to the when conditional, a lockable resource 'example resource' is created (if it doesn't already exist) and a lock is acquired on it. I think this is counter intuitive. The consequence is also really bad – a skipped stage might actually make the whole build hang (possibly for a long time) because it needs to acquire a lock on a busy resource (typically used by another build).

          Assignee:
          Falko Modler
          Reporter:
          Thomas Johansen
          Archiver:
          Jenkins Service Account

            Created:
            Updated:
            Resolved:
            Archived: