Identify build trigger (cron / push)

Is there any way to know if a build was trigger by a push or by a cron trigger ?

I know it’s possible to specify different workflows for each trigger, but that will currently require quite a bit of work on our end.

Any ideas?

Interesting question. I would first check the env vars provided, to see if there is any check you can make there. The obvious one would be that a Git hash will be provided for the push, and maybe not the cron. However, the cron may just pass the value for HEAD here!

If that does not work out, could you call the CircleCI API within your build, to get more build info? Maybe you can get the info there.

Thanks for your reply @halfer. The cron triggered job is getting the normal git commit SHA1.


Sadly, it’s doesn’t look like there are obvious differences in the environment variables between builds started by the two different triggers.

Looks to me that we either have to go full gas onto workflows or nothing at all at this point.

You could look at the last commit, and if it is within the last 10 seconds, assume it is a push, and if it is older than that, assume it is a schedule. Not bulletproof, but it might be OK to start with.