should-run

The should-run global parameter is a Boolean that determines whether Liquibase commands should run. By default, it is set to true.

Uses

If you use a Servlet Listener with Liquibase, you can set the should-run parameter to control whether specific servers run Liquibase commands. This can be useful if you do not want to set the LIQUIBASE_HOST_EXCLUDES or LIQUIBASE_HOST_INCLUDES attributes in your servlet listener, but still need to include or exclude some host names from running Liquibase.

If you are using the JEE CDI Integration for Liquibase, you can use should-run to stop Liquibase from performing updates when the CDI container boots.

If you are making test runs of an application, you can also use should-run to enable Liquibase commands on application startup but disable it on test runs.

Setting the should-run parameter

You can set should-run in four ways:

  • In the Liquibase properties file
  • As a global parameter in the CLI
  • As a JVM system property
  • As an environment variable (Liquibase Pro)

Liquibase properties file parameter

In Liquibase 4.1+, add the following to Liquibase properties file:

liquibase.shouldRun: <true|false>

CLI global parameter

In your command line, use a global parameter with a single Liquibase command:

liquibase --should-run=<true|false> update --changelog-file=dbchangelog.xml

Java system property

In your command line, use the JAVA_OPTS Environment Variable to set a JVM system property:

Mac/Linux syntax:

JAVA_OPTS=-Dliquibase.shouldRun=<true|false>

Windows syntax:

set JAVA_OPTS=-Dliquibase.shouldRun=<true|false>

Note: To use a Liquibase command alongside JAVA_OPTS, add && liquibase <command> to the end of your input.

Environment variable (Liquibase Pro)

In Liquibase Pro, set an environment variable:

Mac/Linux syntax:

LIQUIBASE_SHOULD_RUN=<true|false>

Windows syntax:

set LIQUIBASE_SHOULD_RUN=<true|false>

Note: These environment variable commands only apply to the current shell. If you need to pass an environment variable to a child process without affecting the parent process, you can use the export command on Mac/Linux or the setx command on Windows.

Output

If you run Liquibase with should-run set to false, the output is:

Liquibase did not run because 'liquibase.shouldRun' was set to false