Skip to content

Commit

Permalink
Issue #25: Adding a map to process variables
Browse files Browse the repository at this point in the history
  • Loading branch information
jdewinne committed Jan 12, 2018
1 parent c5089c6 commit 8097a83
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/main/resources/synthetic.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
description="Name of the newly created subrelease."/>
<property name="releaseDescription" category="input" label="Release Description" required="false" size="large"
description="Description of the subrelease."/>
<property name="variables" category="input" required="false"
<property name="variables" category="input" required="false" label="variables (deprecated)"
description="Comma-separated key-value pairs for the values of variables required by the subrelease, e.g. var1=value1,var2=value2"/>
<property name="variableMap" category="input" required="false" label="variables" kind="map_string_string"
description="Map of variables required by the subrelease, where key is the variable name and value the actual value"/>
<property name="asynch" category="input" required="false" kind="boolean" default="false"
description="If [false], the task will wait for the subrelease to finish."/>
<property name="gateTaskTitle" category="input" required="false" kind="string"
Expand Down
10 changes: 6 additions & 4 deletions src/main/resources/xlr/CreateAndStartSubRelease.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# 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.
#


import json
import sys
import time

Expand All @@ -19,18 +19,20 @@ def find_planned_gate_task(tasks):
if task.getType() == "xlrelease.GateTask" and task["status"] == "PLANNED":
return task

def process_variables(variables, updatable_variables):
def process_variables(variables, variable_map, updatable_variables):
var_map = {}
if variables is not None:
for variable in variables.split(','):
var_map[variable.split('=', 1)[0]]= variable.split('=', 1)[1]

var_map.update(variable_map)

for updatable_variable in updatable_variables:
key = str(updatable_variable["key"]).strip("${").strip("}")
if key in var_map:
updatable_variable["value"] = var_map[key]

return str(updatable_variables).replace("u'","'").replace("'", '"').replace("None","null").replace("True","true").replace("False","false")
return json.dumps(updatable_variables).replace("None","null").replace("True","true").replace("False","false")

if xlrServer is None:
print "No server provided."
Expand All @@ -43,7 +45,7 @@ def process_variables(variables, updatable_variables):

# Create Release
updatable_variables = xlr_client.get_updatable_variables(template.id)
vars = process_variables(variables, updatable_variables)
vars = process_variables(variables, variableMap, updatable_variables)
if releaseDescription is None:
releaseDescription = ""

Expand Down

0 comments on commit 8097a83

Please sign in to comment.