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

Run a stage or not based on what triggered the build

XMLWordPrintable

      Not fully designed in my mind but a very handy when condition would be to run based on the build cause. 

      For example to run lengthy performance tests only when triggered by a timer or auto deploy to staging when run by a specific user/role.

      Example:

      stage {
          when {
              triggeredBy timer
          }
      }
      
      stage {
          when {
              triggeredBy user
          }
      }
      
      stage {
          when {
              triggeredBy user('bobby')
          }
      }

      Some more trigger specific parameters might be needed so probably an extension point is needed for this that plugin authors can implement:

      stage {
          when {
              triggeredBy gerrit(event: patchSetCreated, project: 'platform/my-module')
          }
      }
      

      But a lower level plain "class comparer" might solve most general cases until a more specific extension point is implemented by a plugin author

      stage {
          when {
              triggeredBy cause($class: 'DockerRegistryWebHookCause', 'pushNotification.repoName': 'acme/my-app')
          }
      }
      

      Though getting the syntax right will be tricky, so snippetizer support would be good for that.

       

            abayer Andrew Bayer
            rsandell rsandell
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: