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

Provide means of detecting cause of build from declarative pipeline

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      I'd like to be able to perform certain steps on my declartive pipeline when the build has been triggered via a nightly schedule, but not when it is triggered via SCM polling.

        Attachments

          Issue Links

            Activity

            Hide
            ccaraivan Costin Caraivan added a comment -

            Andrew Bayer Is this documented somewhere? How do we use this? Thanks!

             

            Show
            ccaraivan Costin Caraivan added a comment - Andrew Bayer Is this documented somewhere? How do we use this? Thanks!  
            Hide
            jtaboada Jose Blas Camacho Taboada added a comment -

            Costin Caraivan, you can check the documentation here: https://jenkins.io/doc/book/pipeline/syntax/#declarative-pipeline

            And an example is: 

            when { triggeredBy 'SCMTrigger' }

            or TimerTrigger

            Show
            jtaboada Jose Blas Camacho Taboada added a comment - Costin Caraivan , you can check the documentation here: https://jenkins.io/doc/book/pipeline/syntax/#declarative-pipeline And an example is:  when { triggeredBy 'SCMTrigger' } or TimerTrigger
            Hide
            bitwiseman Liam Newman added a comment -

            Bulk closing resolved issues.

            Show
            bitwiseman Liam Newman added a comment - Bulk closing resolved issues.
            Hide
            mcascone Max Cascone added a comment -

            Jose Blas Camacho Taboada The link you provide doesn't take us to an actual example, can you please clarify this (2.5 years later )? thanks!

            Show
            mcascone Max Cascone added a comment - Jose Blas Camacho Taboada The link you provide doesn't take us to an actual example, can you please clarify this (2.5 years later )? thanks!
            Hide
            jtaboada Jose Blas Camacho Taboada added a comment -

            Max Cascone check this
            triggeredBy
            Execute the stage when the current build has been triggered by the param given. For example:

            when

            { triggeredBy 'SCMTrigger' }

            when

            { triggeredBy 'TimerTrigger' }

            when

            { triggeredBy 'UpstreamCause' }

            when

            { triggeredBy cause: "UserIdCause", detail: "vlinde" }

            this will execute only when a build is triggered by TimerTrigger or SCM (choose your poison)

            Show
            jtaboada Jose Blas Camacho Taboada added a comment - Max Cascone check this triggeredBy Execute the stage when the current build has been triggered by the param given. For example: when { triggeredBy 'SCMTrigger' } when { triggeredBy 'TimerTrigger' } when { triggeredBy 'UpstreamCause' } when { triggeredBy cause: "UserIdCause", detail: "vlinde" } this will execute only when a build is triggered by TimerTrigger or SCM (choose your poison)

              People

              Assignee:
              jtaboada Jose Blas Camacho Taboada
              Reporter:
              keirlawson Keir Lawson
              Votes:
              2 Vote for this issue
              Watchers:
              10 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: