As pointed out in the pipeline examples (https://jenkins.io/doc/pipeline/examples/#get-build-cause), there is no native way to retrieve the build trigger cause and therefore it is suggested to  get it by using the `currentBuild.rawBuild` variable:

       

      // Get all Causes for the current build
      def causes = currentBuild.rawBuild.getCauses()
      

       

      However the SCM scripts are not permitted to use the getRawBuild method, as shown bellow:

      Error getting build cause: org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use method org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper getRawBuild

      Can you please consider to change the referred method to whitelisted method.

          [JENKINS-55758] Add Whitelisted method to get the trigger cause

          Filipe Pelica created issue -
          Baptiste Mathus made changes -
          Component/s New: workflow-support-plugin [ 21719 ]
          Component/s Original: build-flow-plugin [ 16533 ]
          Devin Nusbaum made changes -
          Link New: This issue duplicates JENKINS-54227 [ JENKINS-54227 ]
          Devin Nusbaum made changes -
          Link New: This issue duplicates JENKINS-41272 [ JENKINS-41272 ]
          Devin Nusbaum made changes -
          Resolution New: Duplicate [ 3 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]
          Devin Nusbaum made changes -
          Remote Link New: This issue links to "jenkinsci/pipeline-examples#95 (Web Link)" [ 22305 ]

            rodrigc Craig Rodrigues
            filipe_pelica Filipe Pelica
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: