Using XL Release Gate Task for Deciding Future Tasks

| May 15, 2015 | 3 Comments

For all of those working with XL Release, you must be familiar with Gate Task. You can provide conditions in a Gate Task which have to be all checked before you can actually complete the task.

What if you could use those to programmatically check which conditions are met?  One caveat here of course would be to skip the task in case you don’t want to check all conditions.

Here’s how it works

  • Create a new XLR Template with a Gate Task and a Script task after that.
  • You can add a manual step at the start and end of the phase to stop the execution and verify results of script execution.
  • Add the following code snippet inside the Script task
def gatesBeforeTask(task):
  gatesList = []
  for item in phase.tasks:
    if str(item.getTaskType()) == "xlrelease.GateTask":
     gatesList.append(item)
    if item.id == task.id:
     break
  return gatesList
gates = gatesBeforeTask(task)
conditions = gates[0].getConditions()
for condition in conditions:
   print "Condition: " + str(condition.title) + " is : " + str(condition.isChecked()) + "\n"
  • Then start a new release

Screen Shot 2015-05-14 at 2.55.45 PM

  • Continue with the manual task and complete it.
  • Next Open the Gate Task.
  • Select only gate2 and leave gate1 unchecked

Screen Shot 2015-05-14 at 2.56.18 PM

  • Skip Gate Task since you cannot complete it without both the tasks completed

Screen Shot 2015-05-14 at 2.56.41 PM

  • The script task will get executed automatically. Look at the output of script task once its completed

Screen Shot 2015-05-14 at 2.57.11 PM

This prints out the value of the conditions based on which ones were checked or not

 

Now to use the same for Pre Conditions, this is what you can do

  • Add two manual steps after the last(manual) step in your release

Screen Shot 2015-05-14 at 8.07.35 PM

  • In the first manual Step , add this code to precondition. Notice we are setting a result variable at the end of snippet
def gatesBeforeTask(task):
  gatesList = []
  for item in phase.tasks:
    if str(item.getTaskType()) == "xlrelease.GateTask":
     gatesList.append(item)
    if item.id == task.id:
     break
  return gatesList
gates = gatesBeforeTask(task)
conditions = gates[0].getConditions()
for condition in conditions:
 if condition.title == "gate2" and condition.isChecked():
    result = False
  • Now execute the steps
  • Based on the fact that the gate2 condition was checked, you would be skipping the first manual task and going directly onto second

Screen Shot 2015-05-14 at 8.09.40 PM

 

You can see how the step is skipped if the result is False

Have Fun!!


About the Author ()

Amit is the Lead Pre-Sales Solution Architect managing US Pre-Sales Team at XebiaLabs.

  • Anthony Ferrari

    I like this method for setting making decisions while in the middle of the release process.
    The one confusing part of this process is having to skip the gate. This is non-intuitive and would confuse our users. Also – the script code seems complicated…would be nice if it was automatic….
    Suggestion:
    Create a new task type (not sure of a good name – maybe “decision”).
    This task would behave similar to “Gate” except the following.
    1) Task succeeds when any number of checkboxes are checked/not checked. It would only fail on a script error,etc.
    2) Task would automatically set env variables for each checkbox and set them to true or false based on what the user selected (checked). This would enable these values to be easily used by future tasks in the release (preconditions, etc).

    I believe that this would be a powerful way to implement releases that may have different paths based on mid-release decisions. Thanks for listening.

    • amit mohleji

      Thanks Anthony, those are all great suggestions and that kind of task can definitely help in decisioning with the ease of checking user selections. this blog was written as an example of me trying to use the existing functionality with the only drawback of see the task as skipped..
      Regards

      • Anthony Ferrari

        Hi Amit. I also submitted a feature request on this issue – so maybe this blog post is not the best place for this comment. Feel free to delete 🙂
        I do like the method you used here – and plan on using it until my new features can make it into the product. Thanks again!