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

Add Whitelisted method to get the trigger cause

XMLWordPrintable

      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.

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

              Created:
              Updated:
              Resolved: