Run a stage or not based on what triggered the build

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

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.

       

            Assignee:
            Andrew Bayer
            Reporter:
            rsandell
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: