diff --git a/.travis.yml b/.travis.yml index 6ed9885..512d004 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/README.md b/README.md index bd08fb6..642574a 100644 --- a/README.md +++ b/README.md @@ -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 ## @@ -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) diff --git a/build.gradle b/build.gradle index cb87f08..f7ae736 100644 --- a/build.gradle +++ b/build.gradle @@ -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' @@ -22,4 +22,4 @@ license { header rootProject.file('src/main/license/xebialabs_community.license') strictCheck false } -1 + diff --git a/src/main/resources/synthetic.xml b/src/main/resources/synthetic.xml index 78cf82d..e957d4e 100644 --- a/src/main/resources/synthetic.xml +++ b/src/main/resources/synthetic.xml @@ -31,7 +31,8 @@ - + + diff --git a/src/main/resources/xldeploy/XLDeployClient.py b/src/main/resources/xldeploy/XLDeployClient.py index 9c38302..85871d9 100644 --- a/src/main/resources/xldeploy/XLDeployClient.py +++ b/src/main/resources/xldeploy/XLDeployClient.py @@ -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: @@ -170,7 +180,7 @@ 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(): @@ -178,7 +188,8 @@ def deployment_prepare_deployeds(self, deployment, orchestrators=None, deployed_ 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): diff --git a/src/main/resources/xldeploy/deployTask.py b/src/main/resources/xldeploy/deployTask.py index 5612a3c..a802e7b 100644 --- a/src/main/resources/xldeploy/deployTask.py +++ b/src/main/resources/xldeploy/deployTask.py @@ -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)