...
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.
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 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 a new folder which is next to the apache-flexdeploy-tomcat folder name apiext. This location is a change from versions before 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.
Groovy Implementation
Here are high level steps for Groovy implementation. You can use any IDE to prepare this implementation.
...
Tip |
---|
Groovy has the advantage that changes to the API are picked up dynamically without having to recycle the server. |
Groovy Utilities
There are 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.
...
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)
def client = REST.getClient().url(REDMINE_URL + resourcePath);
client.basicauth(REDMINE_USER_NAME, REDMINE_PASSWORD);
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 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 a new folder which is next to the apache-flexdeploy-tomcat folder name apiext. This location is a change from versions before 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.