Category: Urban Code Deploy

  • 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

  • When a value doesn’t exist?

    Recently, I ran into an issue with a resource referece in an Urban Code Deploy (UCD) resource that did not yet exist. When the value, that doesn’t yet exist I found this a great tip (UCD Documentation).

    Change from ${p:resource/value-not-yet-populated} to ${p?:resource/value-not-yet-populated}

    UCD replaces the missing value with an empty string. It saved my sanity and ease of use.