Passing context from Maven to Liquibase on application startup?

Hi! Been tearing my hair out a bit trying to specify a context in my Maven configuration and then having that context be recognized in my Liquibase changelog, and am hoping someone can help. I’m running Liquibase 4.31.1. My pom.xml file looks like this:

<plugin>
  <groupId>org.liquibase</groupId>
  <artifactId>liquibase-maven-plugin</artifactId>
  <configuration>
    <changeLogDirectory>src/main/resources</changeLogDirectory>
    <url>${env.SPRING_LIQUIBASE_URL}</url>
    <username>${env.SPRING_LIQUIBASE_USERNAME}</username>
    <password>${env.SPRING_LIQUIBASE_PASSWORD}</password>
    <defaultSchemaName>public</defaultSchemaName>
    <changelogSchemaName>public</changelogSchemaName>
    <schemas>foo</schemas>
    <contexts>${env.SPRING_PROFILES_ACTIVE}</contexts>
  </configuration>
</plugin>

I’ve confirmed that env.SPRING_PROFILES_ACTIVE is set to “prod”. Meanwhile, my changelog-master.yaml file looks like this:

databaseChangeLog:
  - includeAll:
      path: migrations/
      relativeToChangelogFile: true
      endsWithFilter: .sql
      context: prod

When Liquibase runs on application startup it does not run the migrations. However it will run them fine if I remove context: prod. Am I missing something obvious? Or not obvious?

Thanks!

Jim

Hello @jimb & welcome to the forums!

The behavior you’re seeing suggests that the contexts value in your pom is not being expanded or set appropriately even though you’ve validated that. Is there any DEBUG log output you can share from a startup cycle where the update is not made?