"invalid condition `$TRAVIS_EVENT_TYPE = cron`" in slack channel notification

I’m trying to set up the slack notification for Travis cron job. The purpose is to receive notification on slack only when the build is triggered as cron job.


I’m not able to receive the notification on slack however the cron job is running perfectly on travis.

On Travis, it is showing that the $TRAVIS_EVENT_TYPE = cron condition is invalid. In the docs it is mentioned to check for $TRAVIS_EVENT_TYPE = cron if the build is triggered as cron job.

Travis config output:

notifications.slack.if : invalid condition $TRAVIS_EVENT_TYPE = cron
notifications.slack : skipping notification slack because its condition does not match: $TRAVIS_EVENT_TYPE = cron

Can anyone point out/suggest what is being done wrong here and also what should be the suitable position to place notification in .travis.yml ( top or bottom)? Thanks.

As per Configuring Build Notifications - Travis CI, the if: condition uses the Conditions - Travis CI syntax:

if: type = cron

That type of conditions is also designed to run before a build starts so it may or may not allow to use envvars set during the build.