Skip to content

Commit

Permalink
Merge pull request #1 from kdeenkhoorn/createxldp
Browse files Browse the repository at this point in the history
Compatible with Sybase ASE 16.0 Unix/Linux and build delivers an XLDP file.
  • Loading branch information
Murugesan-30795 committed May 17, 2023
2 parents 247d4c7 + 7b46065 commit 3dae6f2
Show file tree
Hide file tree
Showing 17 changed files with 138 additions and 44 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.gradle
.idea
build
bin
supervisord.log
supervisord.pid
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: java
sudo: false
deploy:
provider: releases
file: build/libs/xld-sybase-plugin-1.0.7.jar
file: build/distributions/xld-sybase-plugin-1.0.10.xldp
skip_cleanup: true
on:
all_branches: true
Expand Down
1 change: 0 additions & 1 deletion License.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

Copyright ${year} ${name}

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
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,29 @@
The Sybase plugin allows you to create a Sybase database client, and Sybase database deployable, to deploy Sybase SQL database.

## Overview
This Sybase SQL plugin works the same as all other SQL deployments. For each SQL file in your SQL deployable, a wrapper.sql file is created to ensure proper error handling. This wrapper.sql file is then passed into the SQL database client, with the appropriate flags. (ex/ host, port, username, password, etc)
This Sybase SQL plugin works the same as all other SQL deployments. For each SQL file in your SQL deployable, a wrapper.sql file is created to ensure proper error handling. This wrapper.sql file is then passed into the SQL database client, with the appropriate flags. (ex/ host, port, username, password, etc)

For this Sybase plugin, the following flags are passed into ISQL:

-S server_name
-D database
-U username
-P password
(Any additionalOptions)
--retserverror
-i inputfile

ref. [Sybase ISQL documentation](http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc34237.1500/html/mvsinst/CIHHFDGC.htm)

The actual command, using Freemarker replacement at runtime, will be:
The actual command, using Freemarker replacement at runtime, will be for Windows:

`"${deployed.container.sybHome}\bin\isql" -S ${deployed.container.address} -D ${deployed.container.dbName} -U "${cmn.lookup('additionalOptions')!}${cmn.lookup('username')}" -P "${cmn.lookup('additionalOptions')!}${cmn.lookup('password')}" --retserverror -i @"${sqlScriptToExecute}"`
`"${deployed.container.sybHome}\${deployed.container.sybOcs}\bin\isql.exe" -S ${deployed.container.address}:${deployed.container.port} -D ${sanitize(deployed.container.dbName)} -U ${sanitize(cmn.lookup('username'))} -P <#if cmn.lookup('password')??>${sanitize(cmn.lookup('password'))}</#if> ${cmn.lookup('additionalOptions')!} --retserverror -i ${sqlScriptToExecute}`

The actual command, using Freemarker replacement at runtime, will be for Unix/Linux:

`"${deployed.container.sybHome}/${deployed.container.sybOcs}/bin/isql" -S ${deployed.container.address}:${deployed.container.port} -D ${sanitize(deployed.container.dbName)} -U ${sanitize(cmn.lookup('username'))} -P <#if cmn.lookup('password')??>${sanitize(cmn.lookup('password'))}</#if> ${cmn.lookup('additionalOptions')!} --retserverror -i ${sqlScriptToExecute}`

Note: An empty password or 'NULL' password is allowed bij Sybase but using an empty password is considered insecure.

To use the plugin, you:

Expand All @@ -39,13 +45,14 @@ To use the plugin, you:
3. Create an application, with a sql.SqlScripts deployable.

You can now execute a Sybase database deployment.
For an example check the examples directory. Here you will find an Infrastructure As Code file to configure your server with the xl(.exe) client and some innocent SQL files to use against your database.

## Installation
1. Download the version of the plugin from the [Releases](https://github.com/xebialabs-community/xld-sybase-plugin/releases) tab, and install in your **XL_DEPLOY/plugins** directory.
1. Download the version of the plugin from the [Releases](https://github.com/xebialabs-community/xld-sybase-plugin/releases) tab, and install in your **XL_DEPLOY/plugins** directory or upload to XL Deploy using the pluginmanager.
2. Restart XL Deploy.

## References

[Introduction to SQL Database Plugin](https://docs.xebialabs.com/xl-deploy/concept/database-plugin.html)
[Introduction to SQL Database Plugin](https://docs.digital.ai/bundle/devops-deploy-version-v.22.3/page/deploy/concept/database-plugin.html)

[Extend the XL Deploy Database plugin](https://docs.xebialabs.com/xl-deploy/how-to/extend-the-xl-deploy-database-plugin.html)
[Extend the XL Deploy Database plugin](https://docs.digital.ai/bundle/devops-deploy-version-v.22.3/page/deploy/how-to/extend-the-xl-deploy-database-plugin.html)
20 changes: 17 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
import org.apache.tools.ant.filters.ReplaceTokens

plugins {
id "com.github.hierynomus.license" version "0.13.0"
id "com.xebialabs.xldp" version "1.0.5"
id "com.github.hierynomus.license" version "0.15.0"
}

defaultTasks 'build'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'maven'
version='1.0.7'
version='1.0.10'

repositories {
mavenLocal()
mavenCentral()
}

license {
header rootProject.file('License.md')
strictCheck false
excludes(["**/*.json", "**/*.ftl"])
ext.year = Calendar.getInstance().get(Calendar.YEAR)
ext.name = 'XEBIALABS'
}

processResources.configure {
filter ReplaceTokens, tokens: [
'project.version': version.toString(),
'project.name': rootProject.name
]
}
2 changes: 2 additions & 0 deletions examples/01-sybase-version-rollback.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sp_version
go
2 changes: 2 additions & 0 deletions examples/01-sybase-version.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sp_version
go
2 changes: 2 additions & 0 deletions examples/02-sybase-version-rollback.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
select @@version
go
2 changes: 2 additions & 0 deletions examples/02-sybase-version.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
select @@version
go
22 changes: 22 additions & 0 deletions examples/infrastructure.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
apiVersion: xl-deploy/v1
kind: Infrastructure
spec:
- name: Infrastructure/my_sybaseserver_com
type: overthere.SshHost
os: UNIX
connectionType: INTERACTIVE_SUDO
address: my.sybaseserver.com
username: OSUser
password: OSPassword
sudoUsername: sybase
children:
- name: my_database
type: sql.SybaseClient
username: DBuser
password: DBpassword
sybHome: /opt/sybase/ase160_3_8
sybOcs: OCS-16_0
dbName: DBname
address: my.sybaseserver.com
port: "8000"
11 changes: 11 additions & 0 deletions src/main/resources/plugin-version.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#
# 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:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
# 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.name@
version=@project.version@
19 changes: 12 additions & 7 deletions src/main/resources/sql/SybaseClient.bat.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +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 @@ -13,18 +14,22 @@ setlocal
<#import "/sql/commonFunctions.ftl" as cmn>
<#include "/generic/templates/windowsSetEnvVars.ftl">

set SYBASE=${deployed.container.sybHome}
set SYBASE_OCS=${deployed.container.sybOcs}

<#if !cmn.lookup('username')??>
echo 'ERROR: username not specified! Specify it in either SqlScripts or its SybaseClient container'
endlocal
exit /B 1
<#elseif !cmn.lookup('password')??>
echo 'ERROR: password not specified! Specify it in either SqlScripts or its SybaseClient container'
endlocal
exit /B 1
<#else>
cd ${deployed.file.path}
<#if !cmn.lookup('password')??>
echo 'WARNING: password not specified! Specify it in either SqlScripts or its SybaseClient container. Using an empty string as a password is considered insecure.'
</#if>

cd ${cmn.scriptsPath()}

${deployed.container.sybHome}\bin\isql.exe -S ${deployed.container.address} -D ${deployed.container.dbName} -U ${cmn.lookup('additionalOptions')!}${cmn.lookup('username')} -P ${cmn.lookup('additionalOptions')!}${cmn.lookup('password')} --retserverror -i ${sqlScriptToExecute}
echo "Executing: ${deployed.container.sybHome}\${deployed.container.sybOcs}\bin\isql.exe -S ${deployed.container.address}:${deployed.container.port} -D ${sanitize(deployed.container.dbName)} -U ${sanitize(cmn.lookup('username'))} -P <#if cmn.lookup('password')??>********</#if> ${cmn.lookup('additionalOptions')!} --retserverror -i ${sqlScriptToExecute}"
"${deployed.container.sybHome}\${deployed.container.sybOcs}\bin\isql.exe" -S ${deployed.container.address}:${deployed.container.port} -D ${sanitize(deployed.container.dbName)} -U ${sanitize(cmn.lookup('username'))} -P <#if cmn.lookup('password')??>${sanitize(cmn.lookup('password'))}</#if> ${cmn.lookup('additionalOptions')!} --retserverror -i ${sqlScriptToExecute}

set RES=%ERRORLEVEL%
if not %RES% == 0 (
Expand Down
28 changes: 16 additions & 12 deletions src/main/resources/sql/SybaseClient.sh.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +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 @@ -10,23 +11,26 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#!/bin/sh

<#import "/sql/commonFunctions.ftl" as cmn>
<#include "/generic/templates/linuxExportEnvVars.ftl">

SYBASE="${deployed.container.sybHome}"
export SYBASE
SYBASE_OCS="${deployed.container.sybOcs}"
export SYBASE_OCS

SYBASE_HOME="${deployed.container.sybHome}"
export SYBASE_HOME

# will override the declarations above if SYBASE_HOME or SYBASE_SID are present
<#include "/generic/templates/linuxExportEnvVars.ftl">
<#if !cmn.lookup('username')??>
echo 'ERROR: username not specified! Specify it in either SqlScripts or its SybaseClient container'
exit 1
<#elseif !cmn.lookup('password')??>
echo 'ERROR: password not specified! Specify it in either SqlScripts or its SybaseClient container'
exit 1
<#else>
# Connect to sybase - isql -c "uid=DBA;pwd=sql;eng=SERV1_iqdemo;links=tcpip(host=SERV2;port=1234)"
"${deployed.container.sybHome}/bin/isql" -c ${cmn.lookup('additionalOptions')!} uid=${cmn.lookup('username')};pwd=${cmn.lookup('password')};eng=${deployed.container.dbName};links=tcpip(host=${deployed.container.address};port=${deployed.container.port})" <<END_OF_WRAPPER
@"${step.uploadedArtifactPath}"
END_OF_WRAPPER
<#if !cmn.lookup('password')??>
echo 'WARNING: password not specified! Specify it in either SqlScripts or its SybaseClient container. Using an empty string as a password is considered insecure.'
</#if>

cd "${cmn.scriptsPath()}"

echo "Executing: ${deployed.container.sybHome}/${deployed.container.sybOcs}/bin/isql -S ${deployed.container.address}:${deployed.container.port} -D ${sanitize(deployed.container.dbName)} -U ${sanitize(cmn.lookup('username'))} -P <#if cmn.lookup('password')??>********</#if> ${cmn.lookup('additionalOptions')!} --retserverror -i ${sqlScriptToExecute}"
"${deployed.container.sybHome}/${deployed.container.sybOcs}/bin/isql" -S ${deployed.container.address}:${deployed.container.port} -D ${sanitize(deployed.container.dbName)} -U ${sanitize(cmn.lookup('username'))} -P <#if cmn.lookup('password')??>${sanitize(cmn.lookup('password'))}</#if> ${cmn.lookup('additionalOptions')!} --retserverror -i ${sqlScriptToExecute}

res=$?
if [ $res != 0 ] ; then
Expand Down
11 changes: 11 additions & 0 deletions src/main/resources/sql/SybaseClientTest.bat.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<#--
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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
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.a
-->

"${container.sybHome}\${container.sybOcs}\bin\isql.exe" -v
12 changes: 12 additions & 0 deletions src/main/resources/sql/SybaseClientTest.sh.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<#--
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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
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.a
-->

#!/bin/sh
"${container.sybHome}/${container.sybOcs}/bin/isql" -v
23 changes: 12 additions & 11 deletions src/main/resources/synthetic.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
<?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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
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.
-->

<synthetic xmlns="http://www.xebialabs.com/deployit/synthetic" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.xebialabs.com/deployit/synthetic synthetic.xsd">

<type type="sql.SybaseClient" extends="sql.SqlClient" description="Sybase ISQL client">
<property name="SybaseClientTestScript" hidden="true" default="sql/SybaseClientTest" />
<property name="clientWrapperScript" hidden="true" default="sql/SybaseClient" />
<property name="username" required="false" description="If set, the user name to use, and none is set on the deployed sql.ExecutedSqlScripts" />
<property name="password" required="false" password="true" description="If set, the password to use, and none is set on the deployed sql.ExecutedSqlScripts" />
<property name="additionalOptions" required="false" size="medium" description="Specify additional options to be passed to the command-line SQL client" />
<property name="sybHome" description="The directory that contains the ISQL installation" />
<property name="dbName" description="The Sybase DB to connect to" />
<property name="address" description="The database IP address" default="localhost" />
<property name="port" description="The TCPIP Port to connect to" />
<property name="username" required="false" description="The Sybase Database user name to use, leave empty if set in the sql.SqlScripts deployable configuration" />
<property name="password" required="false" password="true" description="The Sybase Database password to use, leave empty if set in the sql.SqlScripts deployable configuration" />
<property name="additionalOptions" required="false" size="medium" description="Specify additional options to be passed to the command-line" />
<property name="sybHome" description="The $SYBASE location of Sybase applications, such as Open Client and Open Server" />
<property name="sybOcs" description="The $SYBASE_OCS directory that contains the Open Client installation" />
<property name="dbName" description="The Sybase Database to connect to" />
<property name="address" description="The Sybase Database Hostname or TCP/IP address" default="localhost" />
<property name="port" description="The Sybase Database TCP/IP Port" />
<method name="SybaseClientTest" label="Test Sybase client" description="Test Sybase client installation"/>
</type>
</synthetic>
5 changes: 2 additions & 3 deletions src/main/resources/xl-rules.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<?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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
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.
-->

<!--
Note: If you modify this file and automatic reloading is disabled in `planner.conf`, you must restart the XL Deploy server.
-->
Expand Down

0 comments on commit 3dae6f2

Please sign in to comment.