...
Provide a unique name and description.
Determine whether you will implement the integration in Java or Groovy. Groovy has the advantage that the script is loaded dynamically and does not require a FlexDeploy server recycle when you make changes.
Define properties for the new change management system. Properties are configuration values used by FlexDeploy to connect to the new system and parameterize its usage.
Define Ticket Fields as necessary, which are used to create Ticket or Incidents automatically from FlexDeploy.
Develop either a Java class or Groovy script to perform the integration. Groovy is recommended in most cases, unless there is a Java SDK that will be used to assist in the development.
The examples below demonstrate a custom integration for Zendesk using both Java and Groovy.
...
Code Block | ||
---|---|---|
| ||
def getAdditionalTicketInfo(CMSObject pTicket, String pEnvironmentCode) { // Create notes to add to External Approval def changeNumber = pTicket.getNumber() def map = {'notes': 'Approval note for ' changeNumber + ' added by FD admin'} return map } |
Java Implementation
Here are high level steps for Java implementation. You can use any IDE to prepare this implementation.
...
...
All properties defined are available in Map returned by getProperties method.
...
We are using Zendesk as a use case.
View file | ||
---|---|---|
|
In order to compile your java class, you will need FlexDeployAPI.jar on classpath.
Implement all the methods described in the table in the API Implementation section.
For any failure connecting to the system or if any issues with the data, then you can throw exception. For example throw new ApiException("Invalid credentials.", "");
Once you are ready with unit testing, you can prepare Jar file for your credential store java class and other utility classes. This jar file can be placed on server classpath now.
For Tomcat, put this jar file in apache-tomcat-flexdeploy/libext folder.
If you are using any third-party libraries from your Java implementation, then those jar files will also need to be added to same libext folder. Keep in mind that this can cause issues with server functioning, so be prepared to remove your additional library files.
To pickup changes to your API, the FlexDeploy server must be restarted.
Groovy Implementation
Here are high level steps for Groovy implementation. You can use any IDE to prepare this implementation.
As groovy is able to access FlexDeploy variables and Java classes, you can take advantage of Java libraries from Groovy script. For example, if there is Java library used to access the change management system, you can place those in the libext folder and use those classes from Groovy script. This allows you to keep the dynamic part of implementation in Groovy and use a Java library.
Create a groovy class. Example The example shown below has the methods implemented.
We are using Zendesk as a use case
All properties defined are available as groovy binding variables. For example, properties can be accessed directly like BMC_DOMAIN_NAME, BMC_SALESFORCE_HOST_NAME or BMC_USER_NAME etc
View file name
...
custom CMS.groovy
Implement all the methods described in the table in the API Implementation section
For any failure connecting to the system or if any issues with the data, then you can throw exception. For example throw new ApiException("Invalid credentials.", "");
Tip |
---|
Groovy has the advantage that changes to the API are picked up dynamically without having to recycle the server. |
Groovy Utilities
There are some utility variables provided by FlexDeploy that can be used in your custom Groovy code.
...
log is a FlexDeploy logger variable which should be used to log any information from the groovy class.
...
a number of functions available for use in your custom groovy implementation scripts. View suggestions while editing in the script editing windows by typing Ctrl + Space.
Class | Description |
---|---|
Functions for printing log messages to fd logs | |
Functions for making REST API calls |
Code Block | ||
---|---|---|
| ||
def builder = new groovy.json.JsonBuilder() def root = builder.issue { notes "${pComment}" } String payload = builder.toString(); String ticketNumber = ticket.getNumber(); String resourcePath = REDMINE_TICKET_REST_PATTERN.replaceAll("\\{REDMINE_ISSUE\\}", ticketNumber) fdrestutils.putRequest def client = REST.getClient().url(REDMINE_URL, + resourcePath); client.basicauth(REDMINE_USER_NMAENAME, REDMINE_PASSWORD, resourcePath, payload);); client.put(payload); LOG.info("Rest API create call successful"); |
Java Implementation
Here are high level steps for Java implementation. You can use any IDE to prepare this implementation.
Create java class that extends flexagon.fd.model.integration.cms.api.ChangeManagementSystem. Example shown below has the methods implemented which uses properties map to retrieve the configuration values to connect to the change management system.
All properties defined are available in Map returned by getProperties method.
We are using Zendesk as a use case.
View file name ZendeskServiceIntegration.java
In order to compile your java class, you will need FlexDeployAPI.jar on classpath.
Implement all the methods described in the table in the API Implementation section.
For any failure connecting to the system or if any issues with the data, then you can throw exception. For example throw new ApiException("Invalid credentials.", "");
Once you are ready with unit testing, you can prepare Jar file for your java class and other utility classes. This jar file can be placed on server classpath now.
Put this jar file in $FLEXDEPLOY_HOME/apiext folder. This folder should be next to the apache-tomcat-flexdeploy folder. This is a change from versions prior to 8.0.
If you are using any third party libraries from your Java implementation, then those jar files will also need to be added to same apiext folder. Keep in mind that this can cause issues with server functioning, so be prepared to remove your additional library files.
To pickup changes to your API, the FlexDeploy server must be restarted.