Skip to content

Commit

Permalink
Issue #32: Adding property overrideDeployedProps
Browse files Browse the repository at this point in the history
  • Loading branch information
jdewinne committed Jan 11, 2017
1 parent 8349fa0 commit 14ec5cf
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ deploy:
provider: releases
api_key:
secure: aoVXZyLOBmB4Q2lLKLaqEN8zcqN3K3/3agRBA1znM1PLeqXSE3CwQe6sHkX6BrfMoDDtjqeepDMgJ9TsqJFq+lPY+HuVFzOqGlrWlIZHBUKI3hmfjgM/61CkdK2eBO42Ym4tqCQ4L1Tp42fcrB6M/a/0TGI5ENW2bJk8+ofRT8M=
file: build/libs/xlr-xldeploy-plugin-2.6.2.jar
file: build/libs/xlr-xldeploy-plugin-3.0.0.jar
skip_cleanup: true
on:
all_branches: true
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ permission java.io.FilePermission "plugins/*", "read";
permission java.io.FilePermission "conf/logback.xml", "read";
```

This plugin (2.x.x+) requires XLR 4.8
This plugin (3.x.x+) requires XLR 4.8

## Types ##

Expand All @@ -50,7 +50,8 @@ This plugin (2.x.x+) requires XLR 4.8
* `environment` (ID of the environment to deploy to e.g.: `Environments/Xl Release/XL Release`)
* `orchestrators` (Comma separated list of orchestrators to be used: `parallel-by-deployment-group, parallel-by-container`)
* `deployedApplicationProperties` (Dictionary containing all the deployed application properties to be set (except orchestrators). e.g.: `{"maxContainersInParallel": "2"}`)
* `deployedProperties` (Dictionary containing all the properties to be set. Remark: Each key is an xlrTag in the deployeds - See also [https://github.com/xebialabs-community/xld-xlrelease-plugin](https://github.com/xebialabs-community/xld-xlrelease-plugin), e.g.: `{"Gate1": "{'taskId':'1234567890'}"}`)
* `overrideDeployedProps` (Map contain xpath expression to override deployed properties.) e.g.: {'deployeds/openshift.ResourceModule[@id="Infrastructure/Server/Openshift/project/myapp"]/placeholders/entry[@key="openshift.placeholder"]', 'value'}
* `deployedProperties` DEPRECATED - (use overrideDeployedProps)(Dictionary containing all the properties to be set. Remark: Each key is an xlrTag in the deployeds - See also [https://github.com/xebialabs-community/xld-xlrelease-plugin](https://github.com/xebialabs-community/xld-xlrelease-plugin), e.g.: `{"Gate1": "{'taskId':'1234567890'}"}`)
* `continueIfStepFails` (Will try to continue if a step in the deployment task fails)
* `numberOfContinueRetrials` (Number of times to retry a step)
* `rollbackOnError` (Whether rollback should be done if the deployment fails)
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
id "com.xebialabs.xl.docker" version "1.0.0"
}

version = "2.6.2"
version = "3.0.0"

apply plugin: 'java'
apply plugin: 'idea'
Expand All @@ -22,4 +22,4 @@ license {
header rootProject.file('src/main/license/xebialabs_community.license')
strictCheck false
}
1

3 changes: 2 additions & 1 deletion src/main/resources/synthetic.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
<property name="environment" category="input" default="" required="true" />
<property name="orchestrators" category="input" default="" required="false" />
<property name="deployedApplicationProperties" category="input" default="" required="false" description="A dictionary with key value pairs" />
<property name="deployedProperties" category="input" default="" required="false" description="A dictionary with key value pairs" />
<property name="overrideDeployedProps" category="input" default="" label="Deployed Properties" kind="string" required="false" description="A dictionary with key value pairs. The key being an xpath expression, the value overriding the deployed properties." />
<property name="deployedProperties" category="input" default="" label="Deployed Props (deprecated)" required="false" description="A dictionary with key value pairs - DEPRECATED" />
<property name="rollbackOnError" category="input" kind="boolean" required="false" description="Perform rollback in XL Deploy if the task fails."/>
<property name="cancelOnError" category="input" kind="boolean" required="false" label="Cancel If Not Rollbacking" default="true" description="Cancel the task in XL Deploy if the tasks fails and Rollback On Error is not selected."/>
<property name="failOnPause" category="input" kind="boolean" required="false" default="true" />
Expand Down
15 changes: 13 additions & 2 deletions src/main/resources/xldeploy/XLDeployClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,17 @@ def set_deployed_application_properties(deployment_xml, deployed_application_pro
pkey_xml.text = deployeds_application_properties_dict[key]
return ET.tostring(root)

# deployed_properties must be a string, as the map_string_string type has a bug when putting the '=' in the key.
def override_deployed_properties(deployment_xml, deployed_properties):
root = ET.fromstring(deployment_xml)
if deployed_properties:
deployeds_properties_dict = dict(ast.literal_eval(deployed_properties))
for key in deployeds_properties_dict:
pkey_xml = root.find(key)
pkey_xml.text = deployeds_properties_dict[key]
return ET.tostring(root)

# Deprecated, should be removed starting version 3.1.0
def set_deployed_properties(deployment_xml, deployed_properties):
root = ET.fromstring(deployment_xml)
if deployed_properties:
Expand Down Expand Up @@ -170,15 +180,16 @@ def deployment_prepare_initial(self, deployment_package, environment):
deployment_prepare_initial_response = self.http_request.get(deployment_prepare_initial_url, contentType='application/xml')
return deployment_prepare_initial_response.getResponse()

def deployment_prepare_deployeds(self, deployment, orchestrators=None, deployed_application_properties=None, deployed_properties=None):
def deployment_prepare_deployeds(self, deployment, orchestrators=None, deployed_application_properties=None, overrideDeployedProps=None, deployed_properties=None):
deployment_prepare_deployeds = "/deployit/deployment/prepare/deployeds"
deployment_prepare_deployeds_response = self.http_request.post(deployment_prepare_deployeds, deployment, contentType='application/xml')
if not deployment_prepare_deployeds_response.isSuccessful():
raise Exception("Failed to prepare deployeds. Server return [%s], with content [%s]" % (deployment_prepare_deployeds_response.status, deployment_prepare_deployeds_response.response))
deployment_xml = deployment_prepare_deployeds_response.getResponse()
deployment_xml = add_orchestrators(deployment_xml, orchestrators)
deployment_xml = set_deployed_application_properties(deployment_xml, deployed_application_properties)
deployment_xml = set_deployed_properties(deployment_xml, deployed_properties)
deployment_xml = override_deployed_properties(deployment_xml, overrideDeployedProps)
deployment_xml = set_deployed_properties(deployment_xml, deployed_properties) # Deprecated. Should be remove starting 3.1.0
return deployment_xml

def validate(self, deployment):
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/xldeploy/deployTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# Mapping deployables to the target environment
# deploymentProperties + configure orchestrators
print "Mapping all deployables \n"
deployment = xldClient.deployment_prepare_deployeds(deployment, orchestrators, deployedApplicationProperties, deployedProperties)
deployment = xldClient.deployment_prepare_deployeds(deployment, orchestrators, deployedApplicationProperties, overrideDeployedProps, deployedProperties)

print"Validating the deployment\n"
validation_messages = xldClient.validate(deployment)
Expand Down

0 comments on commit 14ec5cf

Please sign in to comment.