Can I pause or cancel a circle ci build based on environment variable in config.yml?

I need to skip a build from running it.
Suppose there is a env variable in circleci environment CANCEL_BUILD=true
if it is “true”, I need to cancel the build. I do not want to show a failure status because of the cancellation. I want the build status to be cancelled or stopped.

Any help would be appreciated.

See if is what you’re looking for.

Do you want to skip the entire pipeline?

If so, merging with [skip ci] or [ci skip] would be my first suggestion, if it works for your use case.