Skip to content

molivasdat/jenkins-liquibasepro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example of Using LiquibasePro via Jenkins

H2 Database Setup

This example uses a TCP Server connection for the H2 Database. The database needs to be created first.

To create the database using H2 shell:

  1. From the liquibase_pro\lib folder run: java -cp h2*.jar org.h2.tools.Server
  2. In a different window from the liquibase_pro\lib folder run: java -cp h2*.jar org.h2.tools.Shell
  3. Enter the following values:
  • URL: jdbc:h2:~/h2example
  • Driver: org.h2.Driver
  • User: admin
  • Password: password
  1. If you change any of these values you will need to make corresponding changes to the h2_project\liquibase.properties file.

Once the database is created you should be able to view it using the H2 Console:

  1. Run the h2-1.4.200.jar file in liquibase_pro\lib\
  2. This action should bring up the H2 Console Login Screen
  • Setting Name: Generic H2 (Server)
  • Driver Class: org.h2.Driver
  • JDBC URL: jdbc:h2:tcp://localhost/~/h2example
  • User Name: admin
  • Password: password
  1. Click Connect to view the database.

H2 Console Login

Jenkins Setup

  1. Create a Jenkins pipeline and reference the jenkinsfile-examples/updateDb.groovy in the Script Path.
  2. You may need to update the jenkinsfile-examples/updateDb.groovy script to use the appropriate node label for your Jenkins installation.
  3. Depending on your environment you may need to update the bat statements to use sh.

Results

  1. Run the Jenkins script using "Build Now"
  2. After a successful completion, return to the H2 Console and Refresh
  3. You should see 5 new tables created:
  • DATABASECHANGELOG and DATABASECHANGELOGLOCK: LiquibasePro created these tracking tables
  • DEPARTMENT and PROJECT: These tables are created from changesets in h2_project\h2ChangeLog.xml
  • PERSON: This table is created from a SQL script in h2_project\sql\create_person_table.sql

H2 Console With Liquibase Changes

About

Beginners tutorial for running Liquibase Pro updates via Jenkins

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published