Versions Compared

Key

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

...

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");
  }

Update Package to Completed After Production Deployment

You may want to change a package’s status to completed to indicate it successfully deployed to its final environment. This webhook handles changing the status for you using the Workflow Completed Event. You could also update the filter to only update the status for certain projects, releases, instances, etc.

Expand
titleWebhook Listener
Code Block
languagegroovy
​def projectId = EVENT.payload.project.projectId
def packageName = EVENT.payload.packageName
FLEXDEPLOY.updatePackageStatus(projectId, packageName, "COMPLETED")
Expand
titleWebhook Filter
Code Block
languagegroovy
return "SUCCESS".equals(EVENT.payload.executionStatus) && "PRODUCTION".equals(EVENT.payload.environment.environmentCode) && EVENT.payload.packageName != null