Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Create Teams Approval Tasks

@Since 5.5.0.2

See the incoming samples also. They are needed to capture the button clicks that users perform on the Teams messages.

...

This sample sends an interactive message to a Microsoft Teams channel that allows members of the channel to approve or reject an associated FlexDeploy task. As shown in this script, you can add conditions to handle sending to multiple different channels in one listener depending on some condition. (e.g. environment, pipeline, release, etc.) You could also apply similar logic to the webhook listener filter to customize when and where the Teams message should be sent.

See the incoming samples also. An incoming webhook is needed to capture the button clicks that users perform on the Teams messages and ultimately approve/reject the task in FlexDeploy.

...

Expand
titleSend Teams Approval Message Listener
Code Block
languagegroovy
// Function Script - Create Approvable Tasks in Teams Channels (Outgoing Webhook) - Available in 5.5.0.2
String message = MICROSOFTTEAMS.makeTaskCreatedMessageForWebhook(EVENT.payload,"https://<urlToYourFlexDeployServerOrExternalProxy>/flexdeploy/webhooks/v1/<uri setup in Incoming Webhook>");

String webhookUrlBI = "https://flexagon.webhook.office.com/webhookb2/cb7f2430-...9ee6-98a7eae43f9f";
String webhookUrlMule = "https://flexagon.webhook.office.com/webhookb2/cb7f2430-9...-98a7eae43f9f";
String webhookUrlSF = "https://flexagon.webhook.office.com/webhookb2/cb7f2430-96dc-4....-98a7eae43f9f";

if(condition for BI Approval){
MICROSOFTTEAMS.sendTeamsWebhookMessage(webhookUrlBI,message);
} else if(condition for Mule Approval){
MICROSOFTTEAMS.sendTeamsWebhookMessage(webhookUrlMule,message);
} else if(condition for SF Approval){
MICROSOFTTEAMS.sendTeamsWebhookMessage(webhookUrlSF,message);
}

Execute Utility Project

@Since 5.5.0.3

This sample executes a specific FlexDeploy Utility Project called “RunSonar”. In the script below, we are executing the “RunSonar” project whenever a Build workflow with the specified projectId completes successfully. As an extension of the executeUtility function, we can pass ExecuteOptions which allows you to configure which instances the utility project will run on and also the ability to pass inputs and flexfields values to the utility workflow. If no ExecuteOptions are passed as parameters, then the utility will execute on all instances associated in the project configuration.

This function is listening to the ‘Workflow Completed’ Event.

...

Expand
titleExample Groovy Code
Code Block
languagegroovy
//Carry out any custom action you wish for this event. Check out the documentation for reference or ideas.
//Optionally filter out events you dont want to execute by returning false on the filter script tab.
def listenerName = "myListener";
LOG.info("Running listener: ${listenerName}");

def projectId = EVENT.payload.project.projectId;
def projectName = EVENT.payload.project.projectName;
def workflowType = EVENT.payload.workflow.workflowType;
def executionStatus = EVENT.payload.executionStatus;

if (projectId == 516098 && workflowType == "BUILD" && executionStatus == "SUCCESS") {
  LOG.info("Executing Utility Project : ${listenerName}");
  def sonarScanProjectId = FLEXDEPLOY.findProjectId("RunSonar");
  def environmentCode = "DEV";
  
  def workflowRequestId = FLEXDEPLOY.executeUtility(sonarScanProjectId, environmentCode);
  
  if (workflowRequestId) {
    LOG.info("Run Sonar Utility was successfully executed");
  }
  else {
    LOG.severe("Run Sonar Utility failed");
  }