- Reference
- Version ยท 6.0
- Change Automation Reference
context-filter
Last updated: September 29, 2026
Use the --context-filter argument at runtime to list the contexts that apply to the current run. Liquibase runs only the changesets whose contexts attribute matches the contexts you list, plus all changesets that have no context.
Uses
You can only specify context filtering logic in a changeset definition, but you can still specify multiple contexts when running Liquibase in the CLI. However, you can only list out all the contexts that apply to the current Liquibase run.
liquibase update --context-filter="test" --changelog-file=example-changelog.xml
If your changelog includes several changesets with complex and simple context filters such as context="qa and main and !dev" for changeset 1 and context="test" for changeset 2, you need to pass the following on the command line to deploy them:
liquibase update --context-filter="test,qa,main" --changelog-file=example-changelog.xml
Example: If you run the liquibase update --context-filter=1.0 command, it will deploy all changesets with the context set to 1.0 and all changesets without any context or with context="". If you run liquibase update, it will deploy all changesets, whether they have contexts or not.
Note: In Liquibase 4.24.0 and later, --context-filter replaces the deprecated --contexts syntax.
Related filter arguments
Liquibase also provides filter arguments for other changeset attributes: label-filter, teams-filter, releases-filter, keywords-filter, and conditions-filter. The teams, releases, keywords, and conditions filters use straight string matching and require Liquibase Secure 5.2.2 or later. As of Secure 6.0, they also support the @ strict-matching operator.
Syntax
You can set this parameter in the following ways:
Option | Syntax |
Global CLI parameter |
|
Liquibase properties file (defaults file) |
|
Global flow file argument (example) |
|
JVM system property (JAVA_OPTS environment variable) |
|
Liquibase environment variable |
|