Skip to content

Commit

Permalink
Merge pull request #11 from kdeenkhoorn/MakeUp2Date
Browse files Browse the repository at this point in the history
Make plugin compatible with Liquibase v4.11.0 and up
  • Loading branch information
Murugesan-30795 committed May 17, 2023
2 parents bd66d6e + 0537327 commit 1b34280
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ deploy:
provider: releases
api_key:
secure: DegRwl8afRtv4G+iG15e+ZhOCk+H6kOe2lDZCMjpOcKqu9nM2uOSdSZN//gqVFoyiIISLdReQaeB1+sFYlxzxxgByLWjirkdzoCYhtGm6gHoQ9Ua+P80WdtJPwp4x9m+DXjiqu5JgoNiEVQ1BB/KedYXfY0pjR7Yvd5xbEvbNZQ=
file: build/distributions/xld-liquibase-plugin-5.0.1-SNAPSHOT.xldp
file: build/distributions/xld-liquibase-plugin-5.1.0.xldp
skip_cleanup: true
on:
repo: xebialabs-community/xld-liquibase-plugin
Expand Down
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Liquibase plugin #
# Liquibase plugin #

This document describes the functionality provided by the Liquibase plugin.

See the **[XL Deploy Documentation](http://docs.xebialabs.com)** for background information on XL Deploy and deployment concepts.
See the **[XL Deploy v22.3 Documentation](https://docs.digital.ai/bundle/devops-deploy-version-v.22.3/page/deploy/release-notes/releasemanual_deploy_v.22.3.html)** for background information on XL Deploy and deployment concepts.

## CI status

Expand All @@ -27,19 +27,13 @@ See the **[XL Deploy Documentation](http://docs.xebialabs.com)** for background

## Overview

The Liquibase plugin provides a simple way to use Liquibase in XLD.
The Liquibase plugin provides a simple way to use Liquibase in XL Deploy.

This plugin supports Liquibase 'roll back to' tag mode.

## Requirements

* **XL Deploy**: version 4.5.2+
* **Other XL Deploy Plugins**
* [Overtherepy](https://github.com/xebialabs-community/overthere-pylib/releases/latest) version 0.3+

## Installation

You need to install Liquibase on a host accessible by the XLD server.
You need to install Liquibase on a host accessible by the XL Deploy server.

## Execution Logic

Expand Down Expand Up @@ -69,19 +63,24 @@ There are 2 versions of a sample dar available in the _test/resources/sample_dar
### Container _liquibase.Runner_
A liquibase.Runner instance represents a liquibase installation. Below the configuration properties that needs to be set:

* *databaseUsername*: username for the database to connect to (when left out it will use the value in the properties file)
* *databasePassword*: password for the specified username (when left out it will use the value in the properties file)
* *databaseJDBCURL*: JDBC connection URL (when left out it will use the value in the properties file)
* *databaseJDBCDriver*: name of the JDBC driver to use (when left out it will use the value in the properties file)
* *liquibaseJarPath*: path to the main liquibase jar file, i.e. liquibase.jar
* *liquibaseConfigurationPath*: path to the liquibase configuration file, i.e liquibase.properties
* *javaCmd*: command that will be used to launch liquibase java process. Default is "java"
* *driverClasspath*: java classpath used to get database drivers
* *databaseUsername*: username for the database to connect to (when left out it will use the value in the properties file).
* *databasePassword*: password for the specified username (when left out it will use the value in the properties file).
* *databaseJDBCURL*: JDBC connection URL (when left out it will use the value in the properties file).
* *databaseJDBCDriver*: name of the JDBC driver to use (when left out it will use the value in the properties file).
* *driverClasspath*: java classpath used to get database drivers.
* *liquibaseLauncher*: Location of the Liquibase launch script. If this option is configured the options `liquibaseJarPath` and `javaCmd` will be ignored.
* *liquibaseConfigurationPath*: path to the liquibase configuration file, i.e liquibase.properties.
* *liquibaseExtraArguments*: Use to pass extra arguments to the liquibase command.
* *liquibaseJarPath*: path to the main liquibase jar file, i.e. liquibase.jar.
* *javaCmd*: command that will be used to launch liquibase java process. Default is "java".

### Liquibase v4.11.0 and up
With Liquibase version v4.11.0 the [preferred way](https://docs.liquibase.com/workflows/liquibase-community/run-liquibase-without-launch-scripts.html) of starting Liquibase CLI is changed to a launcher script. Therefore the plugin provides the *liquibaseLauncher* option for `xld-liquibase-plugin` version 5.1.0 and up. If this option is configured the contents of *liquibaseJarPath* and *javaCmd* will be ignored. If you wish to use the previous `java -jar liquibase-core.jar` way leave the field *liquibaseLauncher* empty. If you do so with version v4.11.0 and up, provide a `LIQUIBASE_HOME` variable on the client somehow because this variable is required for this version and up.

### Deployable _liquibase.Changelog_

*liquibase.Changelog* is a folder artifact that contains all the xml liquibase changelog
files of the application package.
*liquibase.Changelog* is a folder artifact that contains all the xml liquibase changelog
files of the application package.

__PLEASE NOTE__ this plugin requires that each changeset be marked with the logicalFilePath attribute set. This is so that Liquibase will not take the file name that contains the changeset into consideration when writing database log changes, e.g
<pre>
Expand All @@ -91,3 +90,4 @@ Properties :

* *changeLogFile* specifies the entry point xml changelog file for liquibase.
* *rollbackVersion* specifies the rollback version that will be used to apply a tag after successful changelog update.
* *rollbackVersionPrefix* specifies the prefix added to the tag. Default is 'v'. The tag is composed as follows: <rollbackVersionPrefix><rollbackVersion>, for example: "v1" or "abc-1".
33 changes: 18 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
import org.apache.tools.ant.filters.ReplaceTokens

plugins {
id "com.github.hierynomus.license" version "0.14.0"
id "com.xebialabs.xldp" version "1.0.5"
id "com.xebialabs.xl.docker" version "1.1.0"
id "com.github.hierynomus.license" version "0.15.0"
id "com.xebialabs.xldp" version "1.0.5"
}

version='5.0.1-SNAPSHOT'

version='5.1.0'

defaultTasks 'build'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'maven'

repositories {
mavenLocal()
mavenCentral()
mavenLocal()
mavenCentral()
}

configurations {
distBundle {
transitive = false
}
}

license {
Expand All @@ -27,18 +32,16 @@ license {
exclude('sample_dars/*')
}


dependencies {
compile 'com.xebialabs.overthere:overtherepy:0.0.3'
testCompile "org.hamcrest:hamcrest-core:1.2.1"
testCompile "org.hamcrest:hamcrest-library:1.2.1"
compile 'com.xebialabs.overthere:overtherepy:0.0.4'
distBundle 'com.xebialabs.overthere:overtherepy:0.0.4'
}

processResources.configure {
filter ReplaceTokens, tokens: [
'project.version': version.toString(),
'project.name': rootProject.name
]
filter ReplaceTokens, tokens: [
'project.version': version.toString(),
'project.name': rootProject.name
]
}


7 changes: 5 additions & 2 deletions src/main/resources/liquibase/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2019 XEBIALABS
# Copyright 2023 XEBIALABS
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
Expand All @@ -14,7 +14,10 @@ def none_or_empty(s):
return StringUtils.empty(s)

def build_cmd_line(container):
options = [container.javaCmd, '-jar', container.liquibaseJarPath]
if not none_or_empty(container.liquibaseLauncher):
options = [container.liquibaseLauncher]
else:
options = [container.javaCmd, '-jar', container.liquibaseJarPath]
if not none_or_empty(container.driverClasspath):
options.append("--classpath=%s" % container.driverClasspath)
if not none_or_empty(container.databaseUsername):
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/liquibase/apply_changelog.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2019 XEBIALABS
# Copyright 2023 XEBIALABS
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/liquibase/apply_rollback.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2019 XEBIALABS
# Copyright 2023 XEBIALABS
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
Expand Down
8 changes: 1 addition & 7 deletions src/main/resources/liquibase/apply_tag.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2019 XEBIALABS
# Copyright 2023 XEBIALABS
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
Expand All @@ -8,12 +8,6 @@
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#

#
# THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS
# FOR A PARTICULAR PURPOSE. THIS CODE AND INFORMATION ARE NOT SUPPORTED BY XEBIALABS.
#

from __future__ import with_statement
from overtherepy import OverthereHostSession
from liquibase import *
Expand Down
10 changes: 5 additions & 5 deletions src/main/resources/liquibase/rule.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2019 XEBIALABS
# Copyright 2023 XEBIALABS
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
Expand All @@ -18,10 +18,10 @@ def apply_changelog_steps(d, ctx):
script='liquibase/apply_changelog.py',
jython_context={"container": d.container, "deployed": d})
ctx.addStep(step)
step = steps.jython(description="Create deployment rollback tag [v%s] in liquibase [%s]" % (d.rollbackVersion, d.container.name),
step = steps.jython(description="Create deployment rollback tag [%s%s] in liquibase [%s]" % (d.rollbackVersionPrefix, d.rollbackVersion, d.container.name),
order=CREATE_RESOURCES,
script='liquibase/apply_tag.py',
jython_context={"container": d.container, "tag": "v%s" % d.rollbackVersion})
jython_context={"container": d.container, "tag": "%s%s" % (d.rollbackVersionPrefix, d.rollbackVersion)})
ctx.addStep(step)


Expand All @@ -43,10 +43,10 @@ def handle_destroy(d, ctx):

def handle_modify(pd, d, ctx):
if d.rollbackVersion < pd.rollbackVersion:
step = steps.jython(description="Rollback to tag [v%s] in liquibase [%s]" % (d.rollbackVersion, d.container.name),
step = steps.jython(description="Rollback to tag [%s%s] in liquibase [%s]" % (d.rollbackVersionPrefix, d.rollbackVersion, d.container.name),
order=DESTROY_RESOURCES,
script='liquibase/apply_rollback.py',
jython_context={"container": d.container, "tag": "v%s" % d.rollbackVersion, "deployed": pd})
jython_context={"container": d.container, "tag": "%s%s" % (d.rollbackVersionPrefix, d.rollbackVersion), "deployed": pd})
ctx.addStep(step)
else:
apply_changelog_steps(d, ctx)
Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/liquibase/test.bat.ftl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<#--
Copyright 2019 XEBIALABS
Copyright 2023 XEBIALABS
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Expand All @@ -9,4 +9,5 @@
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->
${container.javaCmd} -jar ${container.liquibaseJarPath} --version
<#if (container.liquibaseLauncher) ??>${container.liquibaseLauncher}<#else>${container.javaCmd} -jar ${container.liquibaseJarPath}</#if> --version

4 changes: 2 additions & 2 deletions src/main/resources/liquibase/test.sh.ftl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<#--
Copyright 2019 XEBIALABS
Copyright 2023 XEBIALABS
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Expand All @@ -11,5 +11,5 @@
-->

#!/bin/sh
${container.javaCmd} -jar ${container.liquibaseJarPath} --version
<#if (container.liquibaseLauncher) ??>${container.liquibaseLauncher}<#else>${container.javaCmd} -jar ${container.liquibaseJarPath}</#if> --version

4 changes: 2 additions & 2 deletions src/main/resources/plugin-version.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2019 XEBIALABS
# Copyright 2023 XEBIALABS
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
Expand All @@ -8,5 +8,5 @@
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#

plugin=@project.artifactId@
plugin=@project.name@
version=@project.version@
26 changes: 14 additions & 12 deletions src/main/resources/synthetic.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2019 XEBIALABS
Copyright 2023 XEBIALABS
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Expand All @@ -17,23 +17,25 @@
<generate-deployable type="liquibase.Changelog" extends="udm.BaseDeployableFolderArtifact" />
<property name="changeLogFile"/>
<property name="rollbackVersion" kind="integer"/>
<property name="rollbackVersionPrefix" kind="string" required="false" default="v" description="Prefix added to rollback tag. Default value 'v'"/>
<property name="baseRollbackTag" default="xld_liquibase_base_version" hidden="true"/>
</type>

<type type="liquibase.Runner" extends="generic.Container" description="Liquibase runner">
<property name="updateScript" hidden="true" default="liquibase/liquibase" />
<property name="testScript" hidden="true" default="liquibase/test" />
<property name="databaseUsername" required="false"/>
<property name="databasePassword" password="true" required="false"/>
<property name="databaseJDBCURL" label="Database URL" required="false"/>
<property name="databaseJDBCDriver" label="Database Driver" required="false"/>
<property name="liquibaseExtraArguments" description="Use to pass extra arguments to the liquibase command." required="false"/>
<property name="liquibaseConfigurationPath" required="false"/>
<property name="liquibaseJarPath" default="liquibase.jar"/>
<property name="javaCmd" default="java"/>
<property name="driverClasspath" required="false"/>
<property name="databaseUsername" label="Database Username" required="false" description="Username for the database to connect to." category="Database parameters"/>
<property name="databasePassword" label="Database Password" password="true" required="false" description="Password for the specified username." category="Database parameters"/>
<property name="databaseJDBCURL" label="Database JDBC URL" required="false" description="JDBC connection URL for the database" category="Database parameters"/>
<property name="databaseJDBCDriver" label="Database Driver" required="false" description="Name of the JDBC driver to use" category="Database parameters"/>
<property name="driverClasspath" label="Database Driver Classpath" required="false" description="Java classpath used to get database drivers" category="Database parameters"/>
<property name="liquibaseLauncher" label="Liquibase launch script" description="Location of the Liquibase launch script" required="false" category="Liquibase parameters"/>
<property name="liquibaseConfigurationPath" label="Configuration file" required="false" description="path to the liquibase configuration file." category="Liquibase parameters"/>
<property name="liquibaseExtraArguments" label="Extra commandline arguments" description="Use to pass extra arguments to the liquibase command." required="false" category="Liquibase parameters"/>
<property name="liquibaseJarPath" label="Liquibase.jar path" description="Location of the Liquibase jarfile" default="liquibase.jar" category="Liquibase compatibility"/>
<property name="javaCmd" label="Java command" description="Command that will be used to launch Liquibase java process." default="java" category="Liquibase compatibility"/>
<method name="test" label="Test Liquibase" description="Test liquibase installation"/>
</type>
</type>

</synthetic>

2 changes: 1 addition & 1 deletion src/main/resources/xl-rules.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!--
Copyright 2019 XEBIALABS
Copyright 2023 XEBIALABS
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Expand Down

0 comments on commit 1b34280

Please sign in to comment.