Deploy Jobs
A deploy job is a command that is executed before a new release gets deployed.
The rollout of the release will only continue if the deploy job finished
successfully. The command of the deploy job has access to the same environment
and binaries as the app runtime. A common use-case for a deploy job is to run
database schema migrations. It can either be specified on creation of the app or
later using the update
command.
If a deploy job fails, the associated release will be set to failed and the previous release will continue to run if there was one to begin with.
Specifying a deploy job on app creation
You can specify a deploy job when creating an application by using various
deploy job related flags on the nctl create app
command.
--deploy-job-command="rake db:prepare" Command to execute before a new release gets deployed. No deploy job will be executed
if this is not specified.
--deploy-job-name="release" Name of the deploy job. The deployment will only continue if the job finished successfully.
--deploy-job-retries=3 How many times the job will be restarted on failure. Default is 3 and maximum 5.
--deploy-job-timeout=5m Timeout of the job. Default is 5m, minimum is 1 minute and maximum is 30 minutes.
$ nctl create app --deploy-job-command="rake db:prepare"
The deploy job will run whenever the new release requires the app to be restarted. The following events will trigger the deploy job to run:
- A new build is available
- The configuration of the application changed (new environment variables, size change, etc)
Specifying a deploy job on other configuration layers
As deploy jobs are part of the configuration of a Deploio application, you can
also specify them on other configuration layers. For
example, you can specify a deploy job via the git configuration source file
.deploio.yaml
:
deployJob:
name: "release"
command: "rake db:prepare"
retries: 3
timeout: 5m
Viewing the status of a deploy job
If a deploy job fails, the associated release will be set to failed and the previous release will continue to run if there was one to begin with. To see the detailed status of a deploy job you can get the full release:
$ nctl get releases brave-scrambler-vc78b -o yaml
[...]
status:
atProvider:
deployJobStatus:
exitTime: 2023-07-18T11:01:47Z
name: brave-scrambler-vc78b-deploy-job
reason: backoffLimitExceeded
startTime: 2023-07-18T11:00:58Z
status: failed
releaseStatus: failure
At the bottom of the release you can see the status and it will show in detail
when and how a deploy job failed. In addition to the status, the deploy job's
log will be written to the normal app log and can be accessed using the nctl logs app
command.