How to identify manually triggered builds in custom plugin

Hey community,

I hope you can help me out here. I am using Netlify together with lerna and multiple gatsby projects.
I have written a custom plugin that is cancelling builds when the subroute is not affected:

const { status } = spawnSync("git", ["diff", "--quiet", "@~..@", "."])
if ( status === 0) {
        `Build was cancelled because current Project is not affected by the latest changes`

This is working just fine, but this leads also to the issue that every build gets cancelled when I trigger it manually through the UI.
Is there any way to detect whether a build has been manually triggered?
I did only find the environment variables about telling me if the trigger is a PR or a webhook, but I did not find anything in regards to manually triggered builds.

Is there a chance to detect them also?

Kind regards,


Hmm… we don’t have an environment variable but one thing you might try would be to call the Netlify API endpoint getDeploy: the title key should be null for a manually triggered deploy.

Along the same lines, you might try the getSiteBuild endpoint- sha should be null for a manually triggered deploy: