Application Processes Branching

Urban Code Deploy (UCD) is a tool we use to manage the deployment of our healthcare platform. I needed to branch between two different processes, and the setup and steps to get branching done between Application processes was not clearly documented.

I built some custom bash logic to switch based on results:

#!/bin/bash
if [ -f /etc/SHORT_CIRCUIT ]
then
echo "result=YES"
else
echo "result=NO"
fi

I created a Post Processing Step

var exit = properties.get('exitCode');

scanner.register("result=", function(lineNumber, line) {
var value=line.replace("result=","");
properties.put("ShortCircuit",value);
});

if (exit == 0) {
properties.put('Status', 'Success');
}
else {
properties.put('Status', 'Failure');
}

scanner.scan();

the scanner matches the text output for a value that has result= in it. I highly suggest having this in your scanner, otherwise you might see ucd propertyValue=script content: which indicates that it did not find any result to set.

Once you get the value in the step, it’ll be available downstream once you set Process Properties. In this case, I pickup the property from the <STEP NAME><SLASH><PROPERTY NAME> and set it into ShortCircuitStatus.

I then use it to make a decision downstream in a switch statement. I do suggest not using a default path in the switch statement, it ensures there is a deterministic and expected outcome of the prior process. I used YES/NO in the switch statement.

References


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.