Skip to content

Commit

Permalink
first code commit
Browse files Browse the repository at this point in the history
  • Loading branch information
JP-work committed Jul 31, 2017
1 parent 9c25852 commit 54f6ce9
Show file tree
Hide file tree
Showing 21 changed files with 389 additions and 16 deletions.
76 changes: 76 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,84 @@

## Preface

This document describes the functionality provided by the Duck Creek plugin.

See the **XL Deploy Reference Manual** for background information on XL Deploy and deployment concepts.


## Requirements

- XL Deploy 5+
- IIS plugin for XL Deploy
- Windows IIS infrastructure
- Robocopy

## Overview

The Duck Creek plugin is an XL Deploy plugin that adds capability for deploying Duck Creek packages to Windows IIS. Team includes manifest.json file into DAR package generated by Jenkins build job. During deployment, XL Deploy utilizes the manifest.json file to determine which files and folders need to be copied to the target server file system, then one deployment step is added for every app server and/or web server entry in the JSON. Additionally, the plugin can issue an IIS restart command and restart the database server with the appropriate JSON fields present.

## Installation

Place the plugin JAR file into your `SERVER_HOME/plugins` directory.

## Usage

1. Go to `Repository - Application`, create a new `duckcreek.Package` and upload your Duck Creek archive file containing manifest.json .

![createDC](dc_create.png)

2. Deploy to your IIS target server, note that one step has been added for every app and web server folder speficied in manifest.json file as well as steps for restarting IIS and database server.
![deployDC](dc_deploy.png)

## Manifest Format information

Example manifest.json file:

```json
{
"appServerFiles":[
{
"source":"Bat\\",
"target":"Bat",
"copytype":"full"
},
{
"source":"Web\\",
"target":"Web",
"copytype":"only-files",
"file":"Web.DEV*.config"
},
{
"source":"Shared\\Bin\\",
"target":"Shared\\Bin",
"copytype":"only-files",
"file":"AIG.CustomPrintJob.dll"
}
],
"webServerFiles":[
{
"source":"Express\\bin\\",
"target":"Express\\bin\\",
"copytype":"full"
},
{
"source":"UserAdmin\\",
"target":"UserAdmin",
"copytype":"only-files"
}
],
"restartIIS":"True",
"updateDBserver":"True",
}
```

The **copytype** field values can be "full" or "only-files". If value of copytype is only-files, we need to replace the files which matche the criteria in the **file** field. The file field should contain whatever wildcard information is required to specify your file(s) i.e. "file":"Web.DEV*.config" above.

## References

[Introduction to the XL Deploy IIS plugin](https://docs.xebialabs.com/xl-deploy/concept/iis-plugin.html)
[IIS Plugin Reference](https://docs.xebialabs.com/xl-deploy-iis-plugin/6.0.x/iisPluginManual.html)

## TODO
From requirements sheet, if file already exists on the server but has changed, replace the file. File checksum used to
determine change.
35 changes: 25 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
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.xebialabs.xl.docker" version "1.0.0"
}

defaultTasks 'build'

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'maven'
version='1.0.0-beta'

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

xlDocker {
compileImage = 'xebialabs/xld_dev_compile'
compileVersion = 'v7.0.0.1'
runImage = 'xebialabs/xld_dev_run'
runVersion = 'v7.0.0.1'
runPortMapping = '14516:4516'
}


sourceCompatibility = 1.7
targetCompatibility = 1.7
version = '1.0.6'


processResources.configure {
filter ReplaceTokens, tokens: [
'project.version': version.toString(),
'project.name' : rootProject.name
]
}
Binary file added dc_create.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dc_deploy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Jul 31 15:18:11 MDT 2017
#Tue May 30 06:52:12 MDT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip
6 changes: 3 additions & 3 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn () {
warn ( ) {
echo "$*"
}

die () {
die ( ) {
echo
echo "$*"
echo
Expand Down Expand Up @@ -155,7 +155,7 @@ if $cygwin ; then
fi

# Escape application args
save () {
save ( ) {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rootProject.name='xld-duckcreek-plugin'
rootProject.name = 'aig-xld-duckcreek-plugin'
56 changes: 56 additions & 0 deletions src/main/resources/duckcreek/GenerateDeployPlan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import json, glob

# build up variable with glob path
path1 = str(deployed.file.path)
path = glob.glob(path1 + "/*.json")

# Locate and store manifest.json information
for f_name in path:
with open(f_name, 'r') as data_file:
data = json.load(data_file)

# Generate deployment for each appserver item
for appFile in data["appServerFiles"]:
if appFile.get('file'):
context.addStep(steps.powershell(
description="Deploying Duck Creek app source: %s " % appFile["source"] ,
script="duckcreek/deploy.ps1",
order=60,
powershell_context={'deployedApplication': deployedApplication, 'source': appFile["source"], 'target': appFile["target"], 'copytype': appFile["copytype"], 'file':appFile["file"]}))
else:
context.addStep(steps.powershell(
description="Deploying Duck Creek app source: %s " % appFile["source"] ,
script="duckcreek/deploy.ps1",
order=60,
powershell_context={'deployedApplication': deployedApplication, 'source': appFile["source"], 'target': appFile["target"], 'copytype': appFile["copytype"]}))

# Generate deployment for each webserver item
for webFile in data["webServerFiles"]:
if webFile.get('file'):
context.addStep(steps.powershell(
description="Deploying Duck Creek app source: %s " % webFile["source"] ,
script="duckcreek/deploy.ps1",
order=60,
powershell_context={'deployedApplication': deployedApplication, 'source': webFile["source"], 'target': webFile["target"], 'copytype': webFile["copytype"], 'file':webFile["file"]}))
else:
context.addStep(steps.powershell(
description="Deploying Duck Creek app source: %s " % webFile["source"] ,
script="duckcreek/deploy.ps1",
order=60,
powershell_context={'deployedApplication': deployedApplication, 'source': webFile["source"], 'target': webFile["target"], 'copytype': webFile["copytype"]}))

# Generate IIS restart on successful deployment
if data["restartIIS"] == "True":
context.addStep(steps.powershell(
description="Issue IIS restart command",
script="duckcreek/iis_restart.ps1",
order=80,
powershell_context={'deployedApplication': deployedApplication}))

# Generate IIS restart on successful deployment
if data["updateDBserver"] == "True":
context.addStep(steps.powershell(
description="Issue database restart command",
script="duckcreek/db_restart.ps1",
order=90,
powershell_context={'deployedApplication': deployedApplication}))
1 change: 1 addition & 0 deletions src/main/resources/duckcreek/db_restart.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Write-Host "Database restart command goes here."
50 changes: 50 additions & 0 deletions src/main/resources/duckcreek/deploy.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
$source1 = "$($deployed.file)\$($source)"
$dest = "C:\\Windows\Temp\$($target)\"

robocopy $source1 $dest /S
$source1 = "$($deployed.file)\$($source)"
$dest = "C:\\Windows\Temp\$($target)"

Write-Host "Source val: $source"
Write-Host "File val: $file"
Write-Host "Deployed file source: $source1"
Write-Host "Deployed file destination: $dest"
Write-Host "COPY TYPE: $copytype"

# Add check to return proper exit code, for some reason ROBOCOPY returns 1 on success o.0
function ROBO_exit_check ($val)
{
Write-Host "val: $val"
if ($val -eq 0)
{
write-host "Robocopy exit code 0: No errors occurred, and no copying was done. The source and destination directory trees are completely synchronized."
}
elseif ($val -eq 1)
{
write-host "Robocopy exit code 1: One or more files were copied successfully (that is, new files have arrived)."
exit 0
}
else
{
Write-Host "Robocopy error code $lastexitcode"
}
}

if ($copytype -eq "full")
{
robocopy $source1 $dest /S
ROBO_exit_check($lastexitcode)
}
elseif ($copytype -eq "only-files")
{
if ($file -eq "")
{
robocopy $source1 $dest /S
ROBO_exit_check($lastexitcode)
}
else
{
robocopy $source1 $dest $file /S
ROBO_exit_check($lastexitcode)
}
}
1 change: 1 addition & 0 deletions src/main/resources/duckcreek/destroy_deploy.bat.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo "destroy script NOOP notification"
1 change: 1 addition & 0 deletions src/main/resources/duckcreek/iis_restart.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoke-command -scriptblock {iisreset}
1 change: 1 addition & 0 deletions src/main/resources/duckcreek/modify_deploy.bat.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo "modify script NOOP notification"
13 changes: 13 additions & 0 deletions src/main/resources/synthetic.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<synthetic xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.xebialabs.com/deployit/synthetic" xsi:schemaLocation="http://www.xebialabs.com/deployit/synthetic synthetic.xsd">

<type type="duckcreek.ExecutedDeploymentPackage" deployable-type="duckcreek.Package" extends="udm.BaseDeployedArtifact" container-type="iis.Server">
<generate-deployable type="duckcreek.Package" extends="udm.BaseDeployableFolderArtifact" copy-default-values="true"/>
</type>

</synthetic>
37 changes: 37 additions & 0 deletions src/main/resources/xl-rules.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<rules xmlns="http://www.xebialabs.com/xl-deploy/xl-rules">

<rule name="duckcreek.ExecutedDeploymentPackage_CREATE" scope="deployed">
<conditions>
<type>duckcreek.ExecutedDeploymentPackage</type>
<operation>CREATE</operation>
</conditions>
<planning-script-path>duckcreek/GenerateDeployPlan.py</planning-script-path>
</rule>

<rule name="duckcreek.ExecutedDeploymentPackage_MODIFY" scope="deployed">
<conditions>
<type>duckcreek.ExecutedDeploymentPackage</type>
<operation>MODIFY</operation>
</conditions>
<planning-script-path>duckcreek/modify_deploy.bat.ftl</planning-script-path>
</rule>

<rule name="duckcreek.ExecutedDeploymentPackage_DESTROY" scope="deployed">
<conditions>
<type>duckcreek.ExecutedDeploymentPackage</type>
<operation>DESTROY</operation>
</conditions>
<steps>
<os-script>
<script>duckcreek/destroy_deploy.bat.ftl</script>
</os-script>
</steps>
</rule>

</rules>
13 changes: 13 additions & 0 deletions src/test/resources/docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#
# 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.
#

xld:
image: xebialabs/xld_dev_run:v7.0.0.1
volumes:
- ~/xl-licenses:/license
- ./../../../../:/data
ports:
- "14516:4516"
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 54f6ce9

Please sign in to comment.