To use this function add it to the class library file named Utilities.ts
GitHub Repository: https://github.com/SimonSparksUK/Orchestrator
Filename: Utilities.ts
Function: logExecutionContext
publicstaticlogExecutionContext(objLogger:Logger):void{
letstrActionName:string=arguments.callee.name.substring(6,arguments.callee.name.length);
// let objWorkflowItemInfo: WorkflowItemInfo = System.currentWorkflowItem();
// System.setLogMarker("SCRIPT: " + objWorkflowItemInfo.getDisplayName());
letobjExecutionContext:ExecutionContext=System.getContext();
letarrParameterName:string[]=objExecutionContext.parameterNames();
arrParameterName.forEach((strParameterName:string):void=>{
letanyParameterValue:any=objExecutionContext.getParameter(strParameterName);
letstrParameterType:string=System.getObjectType(anyParameterValue);
if (strParameterType==="Properties"){
letobjResourceProperties:Properties=anyParameterValueasProperties;
letarrKey:string[]=objResourceProperties.keys;
arrKey.forEach((strKey:string):void=>{
if (strKey==="tags"){
letobjResourceProperties:Properties=objExecutionContext.getParameter("tags");
letarrKey:string[]=objResourceProperties.keys;
arrKey.forEach((strKey:string):void=>{
letanyValue:any=objResourceProperties.get(strKey);
letstrResourcePropertyType:string=System.getObjectType(anyValue);
objLogger.info(`Resource Properties - Tags:${strKey}:${strResourcePropertyType} =${anyValue}`);
});
}
else{
letanyResourcePropertyValue:any=objResourceProperties.get(strKey);
letstrResourcePropertyType:string=System.getObjectType(anyResourcePropertyValue);
objLogger.info(`Resource Properties:${strKey}:${strResourcePropertyType} =${objResourceProperties.get(strKey)}`);
}
});
}
elseif (strParameterType==="Array"){
letarr: []=anyParameterValueas [];
}
else{
objLogger.info(`Execution Context: Key -${strParameterName} - Value -${anyParameterValueasstring}`);
}
});
}Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
