Is there a way I can identify the trigger for the current build during execution. What I want is to identify if the trigger was an SCM change, cron trigger or user trigger. I have multiple triggers defined for a job and want to use trigger type as a parameter in the shell execution script.
You can use the Rest API to get this info; here's an example:
http://jenkins.yourdomain.com/job/job_name/build_number/api/json?tree=actions[causes[shortDescription]]&pretty=true
returns
{
"actions" : [
{
"causes" : [
{
"shortDescription" : "Started by an SCM change"
}
]
},
{
},
{
},
{
},
{
},
{
},
{
}
]
}
One solution is to use the Run Condition Plugin which can run a different shell script depending on the trigger type. It is not the perfect solution, but it will do what you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With