How to integrate Liquibase in the Jenkins pipeline?

We use Oracle database. It looks like there is a plugin called Liquibase Runner.

Hi @sftiit :wave:

To integrate Liquibase in a Jenkins pipeline, you could use the Liquibase plugin available in the Jenkins plugin repository.
It hasn’t been updated in two years, so I don’t know if it still works with recent versions of Jenkins.

Here are the steps to follow:

  1. Install the Liquibase plugin in Jenkins. You can do this by going to Jenkins > Manage Jenkins > Manage Plugins, searching for the “Liquibase Runner Plugin,” and installing it.
  2. Set up your Liquibase project by creating a Liquibase changelog file and setting up your database connection details.
  3. In your Jenkins pipeline, add a build step to run Liquibase. You can do this by adding the following command to your pipeline script:
liquibaseUpdate changelogFile: 'path/to/changelog.xml', url: 'jdbc:postgresql://localhost:5432/mydatabase', username: 'myusername', password: 'mypassword'

Replace the path/to/changelog.xml with the path to your Liquibase changelog file, and replace the url, username, and password with your database connection details.
4. Optionally, you can add additional parameters to the liquibaseUpdate command to customize your Liquibase run. For example, you can add the contexts parameter to specify which contexts to use, or the liquibaseProperties parameter to specify additional Liquibase properties.
5. Save and run your Jenkins pipeline, and Liquibase will be executed as part of the pipeline. If you have multiple concurrent builds for different branches, you can use Jenkins’ built-in feature to limit concurrent builds for the same branch.

1 Like