Skip to main content
Version: Early Access

Listen to events

In Release your custom code can react on the activity log events that are happening inside releases or triggers. These events are published in a lot of different moments during the release or trigger execution.

Example

In the following example, you will see how to listen to one of the Release events and react to it.

important

If you are using maven or gradle to build your plugin, you must add the Digital.ai Deploy/Release Maven repository: https://dist.xebialabs.com/public/maven2 and the following dependency: com.xebialabs.xlrelease:xlr-api:23.3.x.

Gradle

repositories {
...
maven {
url 'https://dist.xebialabs.com/public/maven2'
}
}
dependencies {
...
compile: "com.xebialabs.xlrelease:xlr-api:23.3.0"
}

Maven

<project>
...
<repositories>
<repository>
<id>xebialabs-dist-repo</id>
<name>XebiaLabs maven repository</name>
<url>https://dist.xebialabs.com/public/maven2</url>
</repository>
</repositories>
...
<dependencies>
...
<dependency>
<groupId>com.xebialabs.xlrelease</groupId>
<artifactId>xlr-api</artifactId>
<version>23.3.0</version>
</dependency>
</dependencies>
...
</project>

Here is a sample of the directories inside your plugin structure:

phase-notify-plugin
├── META-INF/services
│ └── com.xebialabs.xlrelease.events.XLReleaseEventListener
└── com/example/plugin
└── PhaseNotifiyListener.java

Release uses java ServiceLoader to discover your custom listeners.

You must create a file with the name com.xebialabs.xlrelease.events.XLReleaseEventListener inside your .jar file under the META-INF/services directory.

META-INF/services/com.xebialabs.xlrelease.events.XLReleaseEventListener

The content of the file is a line with the implementation of the XLReleaseEventListener, in this case:

com.example.plugin.PhaseNotifiyListener

Create a Java class PhaseNotifiyListener inside the com.example.plugin package:


package com.example.plugin;

import com.xebialabs.xlrelease.domain.events.ActivityLogEvent;
import com.xebialabs.xlrelease.events.AsyncSubscribe;
import com.xebialabs.xlrelease.events.XLReleaseEventListener;

public class PhaseNotifiyListener implements XLReleaseEventListener {

private NotificationApi notificationApi = new ....

@AsyncSubscribe
public void notifyCriticalPhaseStarted(ActivityLogEvent event) {
if (e.activityType().equals(PHASE\_STARTED) && e.message().contains(Critical phase)) {
notificationApi.sendAlert(Critical phase started!, all@xebialabs.com);
}
}

}

Your Java class must implement the interface XLReleaseEventListener (this is the same as the file created under META-INF/services). The method with the event logic must be annotated with @AsyncSubscribe. This TestListener is listening to all ActivityLogEvent. If the event type is PHASE_STARTED and contains the critical phase name, it sends an alert to all@xebialabs.com that a critical phase has started.

important

As this class is instantiated by Release, the constructor cannot have any argument.

note

As of Release 8.5.3, ActivityLogEvent has an additional property releaseId of type string.

Using the Configuration API

It is also possible to use the Configuration API from your java class. You must create a private field with the @Resource annotation and Release will inject the interface for you.


package com.example.plugin;

import javax.annotation.Resource;

import com.xebialabs.xlrelease.api.v1.ConfigurationApi;
import com.xebialabs.xlrelease.domain.events.ActivityLogEvent;
import com.xebialabs.xlrelease.events.AsyncSubscribe;
import com.xebialabs.xlrelease.events.XLReleaseEventListener;

public class PhaseNotifiyListener implements XLReleaseEventListener {

@Resource
private ConfigurationApi configurationApi;

@AsyncSubscribe
public void notifyCriticalPhaseStarted(ActivityLogEvent event) {
configurationApi.searchByTypeAndTitle(.......)
...
}

}

Update plugins to replace DeployitEventListener with XLReleaseEventListener

The DeployitEventListener property has been removed and is no longer supported. If you are using this property in your custom plugins, follow these steps to update your custom plugins:

  1. Add a new dependency in build.gradle:

    compile "com.xebialabs.xlrelease:xlr-api:8.2.x"

    You can now add the new events dependencies on the plugin scope.

  2. All classes that have the @DeployitEventListener annotation must be changed to implement XLReleaseEventListener.

  3. All methods on your old classes containing @Subscribe must be replaced with @AsyncSubscribe and the parameter must be changed to ActivityLogEvent.

  4. In the resources folder, create two new folders (META-INF/services) and a file named com.xebialabs.xlrelease.events.XLReleaseEventListener. Using a text editor, open com.xebialabs.xlrelease.events.XLReleaseEventListener and add a text line with the full name of your old class. This is required from Release to detect these "listener" classes outside the Release package.

List of activity types

The following table shows the different activity log types that you can receive in different moments for a release:

Activity log typeDescription
TEMPLATE_CREATEDCreated template
TEMPLATE_DUPLICATEDDuplicated template
TEMPLATE_MOVEDTemplate moved from folder
TEMPLATE_CREATED_FROM_AS_CODECreated template from as code
TEMPLATE_UPDATED_FROM_AS_CODEUpdated template from as code
TEMPLATE_AUTHOR_UPDATEDUpdated template author
RELEASE_TITLE_UPDATEDChanged release title
RELEASE_DESCRIPTION_UPDATEDChanged release description
RELEASE_DUE_DATE_UPDATEDChanged release due date
RELEASE_SCHEDULED_START_DATE_UPDATEDChanged release scheduled start date
RELEASE_OWNER_UPDATEDChanged release owner
RELEASE_TAGS_UPDATEDUpdated release tags
RELEASE_FLAG_STATUS_UPDATEDChanged flag status for release
RELEASE_FLAG_COMMENT_UPDATEDChanged flag comment on release
RELEASE_ABORT_RELEASE_ON_FAILURE_UPDATEDChanged 'Abort release on failure' status on status
COMMENT_ADDEDAdded a comment on task
COMMENT_UPDATEDUpdated comment on task
PHASE_CREATEDCreated a phase in a release
PHASE_RENAMEDRenamed a phase in a release
PHASE_DESCRIPTION_UPDATEDChanged the description of a phase
PHASE_DURATION_UPDATEDChanged the duration of a phase
PHASE_DUE_DATE_UPDATEDChanged the due date of a phase
PHASE_SCHEDULED_START_DATE_UPDATEDChanged the scheduled start date of a phase
PHASE_COLOR_CHANGEDChanged the phase color
PHASE_MOVEDMoved phase
PHASE_DELETEDDeleted phase
PHASE_DUPLICATEDDuplicated phase
PHASE_STARTEDStarted phase
PHASE_FAILEDFailed phase
PHASE_FAILINGPhase started failing
PHASE_RESTARTEDRestarted phase
PHASE_COMPLETEDCompleted phase
PHASE_CLOSEDClosed phase and skipped all its tasks
TASK_CREATEDCreated task
TASK_MOVED_BETWEEN_CONTAINERSMoved a task between containers
TASK_MOVED_WITHIN_CONTAINERMoved a task within a container
TASK_DELETEDDeleted task
TASK_TITLE_UPDATEDChanged the title of a task
TASK_DESCRIPTION_UPDATEDChanged the description of a task
TASK_DURATION_UPDATEDChanged the duration of a task
TASK_OWNER_UPDATEDChanged the owner of a task
TASK_TASK_TEAM_UPDATEDChanged the team of a task
TASK_DUE_DATE_UPDATEDChanged the due date of a task
TASK_SCHEDULED_START_DATE_UPDATEDChanged the scheduled start date of a task
TASK_WAIT_FOR_SCHEDULED_START_DATE_UPDATEDChanged the wait for scheduled start date property of a task
TASK_FLAG_STATUS_UPDATEDChanged the flag on a task
TASK_FLAG_COMMENT_UPDATEDChanged the flag comment on a task
TASK_COPIEDCopied task
TASK_NOTIFICATION_ADDRESSES_UPDATEDChanged the notification addresses of recipients of the task
TASK_NOTIFICATION_CC_UPDATEDChanged the notification list of email addresses that receive the message as CC of a task
TASK_NOTIFICATION_BCC_UPDATEDChanged the notification list of email addresses that receive the message as BCC of a task
TASK_NOTIFICATION_REPLY_TO_UPDATEDChanged the notification email address of the reply message recipient of a task
TASK_NOTIFICATION_PRIORITY_UPDATEDChanged the notification email priority of a task
TASK_NOTIFICATION_SUBJECT_UPDATEDChanged the notification subject of a task
TASK_NOTIFICATION_BODY_UPDATEDChanged the notification body of a task
TASK_SCRIPT_UPDATEDChanged the script of a task
TASK_INPUT_PROPERTY_UPDATEDChanged the input property of a task
TASK_INPUT_PROPERTY_PASSWORD_UPDATEDChanged the password on an input property of a task
TASK_OUTPUT_PROPERTIES_UPDATEDChanged the output property of a task
TASK_PRECONDITION_UPDATEDChanged the precondition of a task
TASK_TYPE_CHANGEDChanged the type of a task
TASK_RELEASE_TITLE_UPDATEDChanged the release title of a task
TASK_RELEASE_TEMPLATE_UPDATEDChanged the release template of a task
TASK_START_RELEASE_FLAG_UPDATEDChanged the start release flag of a task
TASK_RELEASE_VARIABLE_UPDATEDChanged a variable of a task
TASK_RELEASE_TAGS_UPDATEDChanged release tags of a task
TASKS_LOCKEDLocked tasks
TASKS_UNLOCKEDUnlocked tasks
TEAM_CREATEDCreated team
TEAM_UPDATEDUpdated team
TEAM_DELETEDRemoved team
FOLDER_TEAM_MERGEDMerged teams and permissions from a template into a folder
REMOVE_TEMPLATE_TEAMSRemoved teams from template. It will inherit teams and permissions from a folder
GATE_CONDITION_CREATEDCreated condition on a gate
GATE_CONDITION_TITLE_UPDATEDUpdated the condition gate title
GATE_CONDITION_FULFILLEDFulfilled condition on gate
GATE_CONDITION_UNFULFILLEDUnfulfilled condition on gate
GATE_CONDITION_DELETEDDeleted condition from gate
LINK_ADDEDCreated a link between tasks on a group
LINK_REMOVEDRemoved a link between tasks on a group
DEPENDENCY_CREATEDAdded a dependency in a gate
DEPENDENCY_UPDATEDChanged a dependency in a gate
DEPENDENCY_DELETEDDeleted a dependency in a gate
RELEASE_CREATED_FROM_TEMPLATECreated a release from a template
RELEASE_CREATED_FROM_CREATE_RELEASE_TASKCreated a release from a create release task and a template
RELEASE_CREATED_FROM_DSLCreated a release from DSL
RELEASE_RESTORED_FROM_REVISIONRestored a template from a revision
RELEASE_CREATEDCreated an empty release
RELEASE_STARTEDStarted a release
RELEASE_STARTED_FROM_CREATE_RELEASE_TASKStarted a release from a create release task
RELEASE_FAILEDFailed release
RELEASE_FAILINGRelease started failing
RELEASE_RESTARTEDRestarted release
RELEASE_COMPLETEDCompleted release
RELEASE_ABORTEDAborted release
TASK_STARTEDStarted task
TASK_DELAYEDActivated a task with a scheduled start date
TASK_DELAYED_DUE_TO_BLACKOUTActivated a task with a scheduled start date due to a blackout
TASK_COMPLETEDCompleted a task
TASK_COMPLETED_IN_ADVANCECompleted a task in advance
TASK_SKIPPEDSkipped task
TASK_SKIPPED_IN_ADVANCESkipped a task in advance
TASK_FAILEDFailed task
TASK_RESTARTEDRestarted task
TASK_FAILINGTask started failing
TASK_REOPENEDReopened task
TASK_WAITING_FOR_INPUTTask requires input for variables
TEMPLATE_IMPORTEDImported template
PERMISSIONS_UPDATEDUpdated permissions
ATTACHMENT_ADDEDAdded attachment
ATTACHMENT_ADDED_ON_TASKAdded attachment on a task
ATTACHMENT_DELETEDDeleted attachment
ATTACHMENT_DELETED_FROM_TASKDeleted attachment from task
TEMPLATE_ALLOW_CONCURRENT_RELEASES_FROM_TRIGGER_UPDATEDChanged 'Allow concurrent triggered releases' template
RELEASE_VARIABLE_CREATEDCreated release variable
RELEASE_VARIABLE_DELETEDDeleted release variable
RELEASE_VARIABLE_REPLACEDReplaced release variable
RELEASE_VARIABLE_RENAMEDRenamed release variable
RELEASE_VARIABLE_VALUE_UPDATEDChanged the value of a release variable
RELEASE_VARIABLE_PASSWORD_VALUE_UPDATEDChanged the value of a password variable
RELEASE_VARIABLE_NAME_UPDATEDChanged the name of a release variable
RELEASE_VARIABLE_LABEL_UPDATEDChanged the label of a release variable
RELEASE_VARIABLE_DESCRIPTION_UPDATEDChanged the description of a release variable
RELEASE_VARIABLE_REQUIRED_UPDATEDChanged the required flag of a release variable
RELEASE_VARIABLE_SHOW_ON_CREATE_UPDATEDChanged the 'show on create release form' flag of a release variable
GLOBAL_VARIABLE_CREATEDCreated global variable
GLOBAL_VARIABLE_VALUE_UPDATEDChanged the value of a global variable
GLOBAL_VARIABLE_DELETEDDeleted global variable
FOLDER_VARIABLE_CREATEDCreated folder variable
FOLDER_VARIABLE_VALUE_UPDATEDChanged value of folder variable
FOLDER_VARIABLE_DELETEDDeleted folder variable
RELEASE_RISK_PROFILE_UPDATEDChanged the release risk profile

The following table shows the different activity log types that you can receive in different moments for a trigger:

Activity log typeDescription
TRIGGER_CREATEDCreated trigger
TRIGGER_PROPERTY_UPDATEDChanged property of a trigger
TRIGGER_DELETEDDeleted trigger
TRIGGER_ENABLEDEnabled trigger
TRIGGER_DISABLEDDisabled trigger
TRIGGER_EXECUTEDTrigger action executed (e.g. release was created)
TRIGGER_FAILEDTrigger action execution failed
TRIGGER_FILTER_FAILEDEvent-based trigger filter execution failed