Quantcast
Channel: Liquibase Forums
Viewing all articles
Browse latest Browse all 2993

Jenkins - Liquibase using Groovy

$
0
0
Hi, 

We having been using liquibase for our database refactoring using ant build/deployments through Jenkins on a Build Flow Plan. Build Flow plan would trigger another plan which invokes ant liquibase deployment. We haven't simplified it for a long time. 

Now we are trying to simplify the same using one plan to deploy database changesets. We have been successfully able to load liquibase jar and ojdbc connector and invoke liquibase update but it doesnt do any changeset deployment. We tested using on empty database as well. But no success. 

Following are the details. 

Jenkins Workspace: /var/lib/jenkins/workspace/test_new_liquibase
Database Code Directory: /var/lib/jenkins/workspace/test_new_liquibase/_database_
      Above folder have multiple folder structures representing individual schemas and has its changelog,xml

For example: 
Schema Name: scott
Database Code Directory: /var/lib/jenkins/workspace/test_new_liquibase/_database_/scott
changelog file: /var/lib/jenkins/workspace/test_new_liquibase/_database_/scott/changelog.xml

We are doing following set of functions before invoking liquibase update method.

  1. liquibase.changelog.DatabaseChangeLog dc=new liquibase.changelog.DatabaseChangeLog("/var/lib/jenkins/workspace/test_new_liquibase/_database_/scott/changelog.xml")
    dc.setLogicalFilePath("/var/lib/jenkins/workspace/test_new_liquibase/_database_/scott")
    Connection con = DriverManager.getConnection("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=${dbhost})(PORT=${dbport})))(CONNECT_DATA=(SERVICE_NAME=${dbservicename})))",dbusername,dbpassword);
    Liquibase lb = new Liquibase(dc,new liquibase.resource.FileSystemResourceAccessor(), database );
    liquibase.logging.LogFactory.getInstance().getLog().setLogLevel("debug");
    lb.update("");



Output: 
Below output from Groovy Console in local machine

  1. DEBUG 7/12/17 7:11 PM: liquibase: Executing QUERY database command: select count(*) from scott.DATABASECHANGELOGLOCK
  2. DEBUG 7/12/17 7:11 PM: liquibase: Executing QUERY database command: select count(*) from scott.DATABASECHANGELOGLOCK
  3. DEBUG 7/12/17 7:11 PM: liquibase: Executing QUERY database command: SELECT LOCKED FROM scott.DATABASECHANGELOGLOCK WHERE ID=1 FOR UPDATE
  4. DEBUG 7/12/17 7:11 PM: liquibase: Lock Database
  5. DEBUG 7/12/17 7:11 PM: liquibase: Executing UPDATE database command: UPDATE scott.DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = 'PC0E28LT (10.210.224.249)', LOCKGRANTED = to_timestamp('2017-07-12 19:11:17.204', 'YYYY-MM-DD HH24:MI:SS.FF') WHERE ID = 1 AND LOCKED = 0
  6. INFO 7/12/17 7:11 PM: liquibase: Successfully acquired change log lock
  7. DEBUG 7/12/17 7:12 PM: liquibase: Computed checksum for 1499901137229 as 82ead9dfa9d935ffb948537fac940060
  8. DEBUG 7/12/17 7:12 PM: liquibase: Executing QUERY database command: SELECT MD5SUM FROM scott.DATABASECHANGELOG WHERE MD5SUM IS NOT NULL AND ROWNUM=1
  9. DEBUG 7/12/17 7:13 PM: liquibase: Executing QUERY database command: select count(*) from scott.DATABASECHANGELOG
  10. INFO 7/12/17 7:13 PM: liquibase: Reading from scott.DATABASECHANGELOG
  11. DEBUG 7/12/17 7:13 PM: liquibase: Executing QUERY database command: SELECT * FROM scott.DATABASECHANGELOG ORDER BY DATEEXECUTED ASC, ORDEREXECUTED ASC
  12. DEBUG 7/12/17 7:16 PM: liquibase: Release Database Lock
  13. DEBUG 7/12/17 7:16 PM: liquibase: Executing UPDATE database command: UPDATE scott.DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1
  14. INFO 7/12/17 7:16 PM: liquibase: Successfully released change log lock
  15. DEBUG 7/12/17 7:16 PM: liquibase: Executing QUERY database command: select count(*) from scott.DATABASECHANGELOG
  16. INFO 7/12/17 7:16 PM: liquibase: Reading from scott.DATABASECHANGELOG
  17. DEBUG 7/12/17 7:16 PM: liquibase: Executing QUERY database command: SELECT * FROM scott.DATABASECHANGELOG ORDER BY DATEEXECUTED ASC, ORDEREXECUTED ASC


From Jenkins plan no debug messages. 

Are we missing any steps? 

Appreciate your time. 

Thanks

Viewing all articles
Browse latest Browse all 2993

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>