Groovy Libraries allow custom Groovy functions and helpers to be shared and reused across all Groovy scripts in FlexDeploy
Table of Contents | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Creating a Library
Libraries can be viewed and created by navigating to the Administration->Groovy Libraries page. Next click the Create Library 1️⃣ button.
...
Field | Type | Description |
---|---|---|
description | String | Overall description of the function. Markdown can be used. |
params | List of Strings | A list of strings describing the function parameters. See full example below. |
deprecated | boolean (default false) | If true this will indicate the function as deprecated. The name will be |
depAlternate | String | Optional alternative function name to use if this current function is deprecated. |
...
To delete a library simply click the Delete button next to the edit button. Similar to renaming the library - deleting a library that is in use will break any Groovy script using the deleted library.
...
Library Compilation
The following section explains in detail how the script code you write is compiled and made available to each FlexDeploy Groovy script. This information can be helpful in more advanced Groovy Libraries.
The authored script code for each library is wrapped in a class declaration like so
Code Block |
---|
package com.flexagon.groovy.custom;
// imports in the script are moved here
public class LIB_MY_LIB {
// your script code is inserted here
} |
This class is compiled once at server startup and then on each change of the library script it is recompiled.
Finally, when running a Groovy script, an instance of this library class is instantiated and made available to the script.