Versions Compared

Key

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

...


Method Name

Parameter(s)
Return Type

Description

createTicket

Map<String,Serializable> pTicketFieldsvoid

Creates a Change Request ticket using the pDescription and pComment

createIncident

Map<String,Serializable> pTicketFieldsString

Creates an Incident ticket using the pDescription and pComment

findCMSObjectByType

String pCMSObjectNumber

ChangeManagementSystem.CMSObjectType pCMSObjectType

void

Find a "ticket" or "incident" using the object identifier and type. The object type will be TICKET or INCIDENT, and implementations must translate that into the corresponding object type within the provider (e.g. Problem, Request, etc.) 

isTicketApproved

CMSObject pTicket

String pEnvironmentCode

BooleanReturns whether the ticket is approved in the CMS. 
isTicketRejected

CMSObject pTicket

String pEnvironmentCode

BooleanReturns whether the ticket is rejected in the CMS.

checkConnection

N/Avoid

This method should invoke any status or heath check URL of the change management system to ensure the system is up and running and a connection can be authenticated.  This method will be called when the Test Connection button is clicked on the CMS Instance.

isDoPolling

N/A

void

Returns whether FlexDeploy should automatically poll the CMS to identify whether the ticket is approved or rejected.  If polling is enabled FlexDeploy will lookup the ticket every 1 minute using findCMSObjectByType and then check the status using the isTicketApproved and isTicketRejected methods.

If polling is not enabled, the CMS or another external system is responsible for approving/rejecting the associated task using the FlexDeploy REST API.

getTicketURLCMSObject pCMSObjectStringreturns the REST API url of the change ticket


Tip

If your usage of the CMS will not include the automated creation of TICKET or INCIDENT objects the API can be simplified.  Although createTicket and createIncident are required to be implemented, if you are not using these auto-creation features you can choose to simply throw an exception from one or both methods as appropriate.

Code Block
languagejava
themeMidnight
titleExample
throw new UnsupportedOperationException("createIncident is not supported for Zendesk CMS integration");



Tip
titleAdd custom task notes
@since 5.5.0.2

With out-of-the-box CMS providers including BMCHelixRemedyforce, ServiceNow, JiraITSM, and Freshworks, you have the ability to add notes to a FlexDeploy External Approval upon approval or rejection. Custom Change Management Systems have the same functionality. Can do so by overriding the following getAdditionalTicketInfo in your Groovy API. It takes CMSObject and environment code as parameters and must return a Map<String, String>.

Code Block
languagegroovy
themeMidnight
titleSimple Example
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
}



...

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.
  • fdrestutils is a utility object available to use FlexDeploy API to invoke any REST API.
  • testConnection(String pHostName, String pUrl, String pUserName, String pPassword)
  • getRequest(String pHostName, String pResourcePath, String pUserName, String pPassword) - Returns javax.json.JsonObject
  • postRequest(String pHostName, String pUserName, String pPassword, String pResourcePath, String pResourceName, String pPayload) - Returns boolean
  • putRequest(String pHostName, String pUserName, String pPassword, String pResourcePath, String pPayload) - Returns boolean See the Java docs for more details on the functions available.


    Code Block
    languagegroovy
    themeEmacs
    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(REDMINE_URL, REDMINE_USER_NMAE, REDMINE_PASSWORD, resourcePath, payload);