Issue
How can I run a Heroku CLI command from the Heroku Scheduler?
Resolution
The CLI can be installed with the CLI buildpack and you'll need to set a valid API key on your application to run any application-specific commands.
Here are the steps you can follow:
-
You can generate a key by using
heroku authorizations:create
on a machine that is currently running an authenticated version of the Heroku CLI and set that key as a config variableHEROKU_API_KEY
for your application. -
Add the buildpack to your app:
- To use the latest stable version from the Buldpack Registry run
heroku buildpacks:add heroku-community/cli
- To use the edge version (i.e. the source code in the GitHub repository) run
heroku buildpacks:add https://github.com/heroku/heroku-buildpack-cli
.
- To use the latest stable version from the Buldpack Registry run
These steps should help you run Heroku CLI commands from one-off dynos which the Heroku Scheduler add-on as well runs on.