Versions Compared

Key

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

...

The Default Listener (POST Webhook)

Note that this function may no longer needed as Release Settings incorporate this functionality.

When creating a new Listener, the script will default to the below which simply forwards the payload via a REST Post request. This script emulates an outbound webhook in the truest sense since no payload modification or logic is done. Simply update the postUrl variable with your endpoint and its ready to go.

...

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 = "endReleaseListener";
LOG.info("Running listener: ${listenerName}");
         
if(EVENT.payload.environment.environmentCode.equals("PROD")){
     LOG.setMessage("Release ${EVENT.payload.release.releaseName} has completed moving through the pipeline. Ending release.");
     FLEXDEPLOY.endReleaseforceEndRelease(EVENT.payload.release.releaseId);
}

...

Update Package to Completed After Production Deployment

Info

Note that this function may no longer needed as Release Settings incorporate this functionality.

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 update the filter to only update the status for certain projects, releases, instances, etc. The listener also handles removing the package from its release first, as a package cannot be marked completed if it’s in an active release.

...

Code Block
languagegroovy
​def releaseName = EVENT.payload.release.releaseName
def projectId = EVENT.payload.project.projectId
def packageName = EVENT.payload.packageName

if (releaseName != null)
{
  FLEXDEPLOY.removeProjectsFromRelease(releaseName, [new flexagon.fd.model.pojos.rest.release.ReleaseProjectsPojo(projectId, packageName, false)])
}

FLEXDEPLOY.updatePackageStatus(projectId, packageName, "COMPLETED")

...