I'm trying to figure out how to determine what caused a build to run from inside a scripted Jenkinsfile. The reason is that I have a script in a docker container that I want to run on a cron job, so when the cron job triggers, I just want it to run the container, but when I push changes, I want it check out the code, rebuild the container, run static code analysis, run tests, etc. There's no need for all of that on a cron run.
How can I get the cause? I tried currentBuild.getCauses()
, but I get
groovy.lang.MissingMethodException: No signature of method: org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper.getCauses() is applicable for argument types: () values: []
I tried println currentBuild.getRawBuild().getCauses()
, but got
org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use method org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper getRawBuild
How cna i get the cause of a build in my jenkinsfile?