diff --git a/.travis.yml b/.travis.yml index 851928b..c741e95 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/README.md b/README.md index fd3e6df..b100933 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -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
@@ -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:, for example: "v1" or "abc-1". diff --git a/build.gradle b/build.gradle index 3c56414..989d5a4 100644 --- a/build.gradle +++ b/build.gradle @@ -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 { @@ -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 + ] } diff --git a/src/main/resources/liquibase/__init__.py b/src/main/resources/liquibase/__init__.py index 670f189..ae3cca2 100644 --- a/src/main/resources/liquibase/__init__.py +++ b/src/main/resources/liquibase/__init__.py @@ -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: # @@ -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): diff --git a/src/main/resources/liquibase/apply_changelog.py b/src/main/resources/liquibase/apply_changelog.py index 239a44a..ab78934 100644 --- a/src/main/resources/liquibase/apply_changelog.py +++ b/src/main/resources/liquibase/apply_changelog.py @@ -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: # diff --git a/src/main/resources/liquibase/apply_rollback.py b/src/main/resources/liquibase/apply_rollback.py index 3eb3c19..8225f5c 100644 --- a/src/main/resources/liquibase/apply_rollback.py +++ b/src/main/resources/liquibase/apply_rollback.py @@ -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: # diff --git a/src/main/resources/liquibase/apply_tag.py b/src/main/resources/liquibase/apply_tag.py index 1e9dc52..38c3d9f 100644 --- a/src/main/resources/liquibase/apply_tag.py +++ b/src/main/resources/liquibase/apply_tag.py @@ -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: # @@ -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 * diff --git a/src/main/resources/liquibase/rule.py b/src/main/resources/liquibase/rule.py index 651f8ff..871c118 100644 --- a/src/main/resources/liquibase/rule.py +++ b/src/main/resources/liquibase/rule.py @@ -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: # @@ -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) @@ -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) diff --git a/src/main/resources/liquibase/test.bat.ftl b/src/main/resources/liquibase/test.bat.ftl index dd93060..b9901e1 100644 --- a/src/main/resources/liquibase/test.bat.ftl +++ b/src/main/resources/liquibase/test.bat.ftl @@ -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: @@ -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 + diff --git a/src/main/resources/liquibase/test.sh.ftl b/src/main/resources/liquibase/test.sh.ftl index 0d6838a..3b71d54 100644 --- a/src/main/resources/liquibase/test.sh.ftl +++ b/src/main/resources/liquibase/test.sh.ftl @@ -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: @@ -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 diff --git a/src/main/resources/plugin-version.properties b/src/main/resources/plugin-version.properties index c37303d..25509cd 100644 --- a/src/main/resources/plugin-version.properties +++ b/src/main/resources/plugin-version.properties @@ -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: # @@ -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@ diff --git a/src/main/resources/synthetic.xml b/src/main/resources/synthetic.xml index 9377cd0..0a832cb 100644 --- a/src/main/resources/synthetic.xml +++ b/src/main/resources/synthetic.xml @@ -1,7 +1,7 @@