Jobs
How to create jobs
Last updated
Was this helpful?
How to create jobs
Last updated
Was this helpful?
Jobs are used to run a command that ultimately terminates. They are distinct from services (which stay running) and cron jobs (which run on a schedule).
Some common use cases for jobs include:
Set-up scripts
Database migrations
Compiling assets
Validation scripts
To create jobs in Release, edit your "Environment Configuration" under Settings.
At the end of the YAML, add a section called jobs
and define any jobs you want to run following the example below.
jobs:
- name: migrate
command:
- "./run-migrations.sh"
from_services: backend
- name: setup
command:
- "./run-setup.sh"
from_services: backend
cpu:
limits: 100
requests: 100
memory:
limits: 1Gi
requests: 1Gi
Press Save as new version.
Click Deploy to apply this new configuration to your environment. This will redeploy your existing instances, and also add a new one to run the job you defined.
Wait for the new environment to deploy. If you used the configuration from the example above, you should see a new instance come up every five minutes. Viewing the logs of that instance will confirm that the job ran as expected.
Instead of choosing a from_services
to base your job on, you can define image
to base your job on a Docker image. You can find more examples and the full schema in the schema docs.