Deploy hooks for cron jobs

Hi all,

I’ve got my CI setup firing a deploy when everything passes (instead of automatic deploys) using the deploy hooks - and this works fine for web and worker processes. Cron jobs don’t have deploy hooks though - at least, I’m not spotting them. Is it somehow possible to rig one up?

Thanks,


Pat

Hi @pat, at the moment, we do not have deploy hooks for cron jobs. We do have a feature request around this, which you can upvote to receive future updates on: Add deploy hook for cron jobs | Feature Requests | Render

We do have one-off jobs though, which can be triggered via our API: Run one-off tasks based on your existing services with Render Jobs. | Render. Our API is still in early access so let me know if you’d like to be included in the early access program.

Thanks for your reply Jade. I’m not sure I quite follow, though. Are you suggesting I could invoke once-off jobs via my web process, from a cron process - and so because the cron process never/rarely changes, it doesn’t need semi-automated deploys? I could see this potentially working, but it feels quite kludgy - essentially firing off two processes when one would ideally be good enough, and having to delve into an API as opposed to just pinging a deploy hook with curl.

I’ll consider it - and would appreciate access for the API if possible! - but right now I suspect it may be too much effort as a workaround.

Hi @pat, I’ve given you access to the API, in case you’d like to check it out. You can create an API key from your account settings page, and we have our documentation, which we are adding to here: https://apidocs.preview.render.com/

On second thought, I do agree with you that using one-off jobs might not be a suitable alternative for what you are trying to achieve. For some reason I was thinking along the lines of triggering the actual job vs. triggering the deploy. But we do still have deploy hooks for cron jobs in our backlog, so hopefully we’ll be able to add parity around this soon!

1 Like

Now that there’s an extensive API that includes deploys, I’ve been able to script up a solution to this. I’ve got the following command being executed for each of my cron jobs (as well as standard web/worker services, to be consistent rather than mixing it with deploy hooks):

curl --request POST \
     --url "https://api.render.com/v1/services/$SERVICE_ID/deploys" \
     --header "Accept: application/json" \
     --header "Authorization: Bearer $RENDER_API_KEY" \
     --header "Content-Type: application/json" \
     --write-out '%{http_code}' \
     --silent \
     --output /dev/null

(I’m keeping the output to just the status code, to avoid any secrets being output within my CI builds.)

1 Like