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

Stage locks are created for skipped stages in declarative pipeline

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).

            famod Falko Modler
            thxmasj Thomas Johansen
            Votes:
            5 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved: