How to determine whether the Jenkins build was started by a user or the scheduler?
I'm not sure if there is a simple way to check if the &quot;scheduler&quot; kicked off the job, but you can check if a user executed the job.
In your Jenkins job, check for the presence of the BUILD_USER_ID environment variable. If it is present, retrieve the value and send your email to the specific user(s) (scenario 1). If it is not present, a non-user has executed the job, and you can email the users listed on the last successful check-in (scenario 2).
If you are looking for methods outside of the Jenkins job, you can also use the Jenkins API (http://jenkinsurl/job/[JobName]/[BuildNumber]/api/json?pretty=true) and parse the BUILD_USER_ID from the output.