> For the complete documentation index, see [llms.txt](https://developer.collibra.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.collibra.com/workflows/designing-workflows/processes/process-execution/the-groovy-lib-folder.md).

# The "groovy-lib" folder

The **groovy-lib** folder is a specific directory in your Collibra environment customization files that allows you to deploy and share Groovy scripts across multiple workflow processes.

By placing Groovy scripts in this folder, you can create custom libraries and helper classes that are accessible to any workflow script task. This promotes code reusability, simplifies maintenance, and helps to enforce consistent behavior in your workflows:

Reusability

Write a function once and call it from any workflow. This saves time and reduces the chance of errors.

Maintainability

Update a script in one place, and the changes are automatically reflected in all workflows that use it.

Consistency

Ensure that common tasks, such as sending notifications or integrating with an external system, are performed in the same way everywhere.

Simplicity

Keep your workflow definitions cleaner and more focused on the business process by moving complex code logic into external libraries.

## When to use the "groovy-lib" folder

You should use the **groovy-lib** folder when you have Groovy code that you want to reuse across different workflows or when you want to separate complex logic from your business process definitions. Some examples include:

* Utility classes with helper methods for string manipulation, date calculations, or API interactions.
* Standardized methods for logging or error handling.
* Connectors for integrating with external systems.

For code that is specific to a single workflow and not intended for reuse, you can continue to write it directly in the workflow script tasks. The core value of the groovy-lib folder is to store scripts that are common to a large number of tasks.

## Uploading scripts to the "groovy-lib" folder

To get started with the **groovy-lib** folder, use the console export file mechanism to add a customization package to Collibra. The workflow engine automatically makes any GROOVY files from the **groovy-lib** available in your workflow scripts.

{% stepper %}
{% step %}
Create a console export file with customizations.

1. Open Collibra Console with a user profile that has at least the **ADMIN** role.\ <i class="fa-chevrons-right">:chevrons-right:</i> Collibra Console opens with the **Infrastructure** page.
2. In the main menu, click **Console Export Files**.\ <i class="fa-chevrons-right">:chevrons-right:</i> The Console Export Files page appears.
3. Above the table, to the right, click **Create Console Export File**.
4. In the **Create Console Export File** dialog box, enter the required information:

   Environment

   The Collibra environment for which to create an export file.

   Customizations

   This ensures that if there is a **groovy-lib** folder it gets downloaded and allows you to upload a new or modified one.

   <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>The configuration is always included in export files for consistency and reliability.</p></div>
5. Click **Create Export File**.
   {% endstep %}

{% step %}
Once Collibra finishes processing the file, download it.
{% endstep %}

{% step %}
Extract the contents of the archive.
{% endstep %}

{% step %}
Add your Groovy scripts to **dgc** → **groovy-lib**.

{% hint style="info" %}
If this folder structure does not exist, create it.
{% endhint %}
{% endstep %}

{% step %}
Go to the containing directory of the extracted files, select all of them, and add then to a ZIP archive.

{% hint style="info" %}
Do not archive the containing directory. Select only the individual files and directories to have the same structure as the original ZIP file.
{% endhint %}
{% endstep %}

{% step %}
Upload ZIP archive to your Collibra environment:

1. Open Collibra Console with a user profile that has at least the **ADMIN** role.\ <i class="fa-chevrons-right">:chevrons-right:</i> Collibra Console opens with the **Infrastructure** page.
2. In the main menu, click **Console Export Files**.\ <i class="fa-chevrons-right">:chevrons-right:</i> The Console Export Files page appears.
3. Above the table, to the right, click **Upload Console Export File**.
4. In the **Upload Console Export File** dialog box, enter the required information:

   Not password protected

   The option to choose for new console export files.

   Retain for

   The retention period for the export file, after which the file is automatically removed.
5. Select the ZIP archive you created.\ <i class="fa-chevrons-right">:chevrons-right:</i> The upload starts automatically.
   {% endstep %}

{% step %}
Once the upload finishes, apply the console export file:

1. In the row of the export file you have uploaded, click <img src="/files/54g3eQZWDVoUaIFJVXcc" alt="" data-size="line">**Apply Restore**.
2. In the **Applying console export file** dialog box, enter the required information:

   Environment

   The Collibra environment where you want to apply the export file.

   Export

   The export file you have uploaded.

   Customizations

   This ensures that the **groovy-lib** folder and your reusable scripts get applied.
3. Click **Apply console export file**.

{% hint style="info" %}
The console export file is applied to the selected environment. The time to apply an export file depends on the amount of data it contains. During this time, your environment is unavailable. The process is complete when all services in your environment have the running status again.
{% endhint %}
{% endstep %}
{% endstepper %}

## Using the "groovy-lib" folder

If you use the **groovy-lib** mechanism to create reusable functions across workflows, consider that by default, the entire content of the **groovy-lib** folder is included in each script task before compilation. Since compilation time increases with the number of lines of code, including unused reusable functions can negatively affect performance.

To mitigate this issue, enable the **Don’t attach Groovy libs by default** option in Collibra Console. For scripts that require reusable functions, explicitly add a `// #importFile` statement at the beginning of the script to load the relevant files:

```
// #importFile resourcePrinter.groovy
// #importFile processDetailsPrinter.groovy
```

Rules for using `#importFile`:

* The `#importFile` statement must be the first line in the script, even before the imports section. Any whitespace character at the beginning of the script is ignored.
* Whitespace characters are allowed before and after `//`.
* There cannot be any whitespace character between `#` and `importFile`.
* Whitespace characters are allowed between `#importFile` and the Groovy file name.
* If a referenced Groovy file is not found in the **groovy-lib** folder, it is silently ignored.

## Additional resources

* [Create a console export file](https://productresources.collibra.com/docs/collibra/latest/Default.htm#cshid=DOC0392)
* [Download a console export file](https://productresources.collibra.com/docs/collibra/latest/Default.htm#cshid=DOC0397)
* [Upload a console export file](https://productresources.collibra.com/docs/collibra/latest/Default.htm#cshid=DOC0403)
* [Apply a console export file](https://productresources.collibra.com/docs/collibra/latest/Default.htm#cshid=DOC0400)
* [Script task performance](https://developer.collibra.com/tutorials/script-task-performance)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.collibra.com/workflows/designing-workflows/processes/process-execution/the-groovy-lib-folder.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
