Exit a Flow file
Using the Control command, exit,
in a flow file allows you to exit running the flow if there are not any pending changesets present. This enhances your efficiency when using a flow file by eliminating the need to run checks on unchanged changesets or generate drift reports when no changes are being applied.
Note: Available with a Liquibase Pro license key in +4.30.0
Procedure
-
To use the
exit
Control command in a Control step of a Flow file, you must run thestatus
command within the Flow file and set the next-type
argument to-type: control
along with the necessary arguments.CopyInclude the status command and type: control in the flow file- type: liquibase
command: status
- type: control exitCode: 0
This is an integer and does not require quotes in its syntax.exitMessage: "a string"
This is a string and requires quotes in its syntax.- Set the
exitCode
to0-4
depending on the severity you want to trigger. - Set the
exitMessage
.
Example:Exiting with an error status of 0 because the database is up-to-date.
- Set the
if: "status.changeset.Count == 0"
. This will trigger the command to exit if Liquibase detects there are no pending deployed changesets.
This completes all of the Flow file changes to enable theexit
control command. Next, you will move back to the CLI to run the Flow.CopyComplete Flow file examplestages:
stage-status-check:
#
# Exit if no pending changes to deploy
#
- type: liquibase
command: status
- type: control
if: "status.changesetCount == 0"
command: exit
cmdArgs: {exitCode: 0, exitMessage: "Exiting with an error status of 0 because the database is up-to-date"} - After you set up your Flow file, run the
flow
command in the CLI:
Note: If you want to use Labels, add them here. You must add them under the status
command, not the exit
command.
The exit command has two command arguments:
Note: A child Flow cannot cause a parent flow to exit
. status
commands must be run in the same Flow file that contains the control being checked.
liquibase flow --flow-file=flows/<path/to/your/flowfile>.yaml
The type:control action runs, and if no new changesets are detected, Liquibase exits the Flow.