Dynamic Forms

Use the Dynamic Forms feature to simplify the process of adding variables to your ScriptRunner Groovy scripts. Dynamic Forms allow you to create complex scripts with flexible variables that can be shared with multiple users, allowing one script to be used for various use cases.

Inline scripts are often copied and pasted, with minor changes made for different use cases. This approach requires maintenance for each usage of the script. Using Dynamic Forms, create flexible scripts with annotated variables that can be stored as files, reducing maintenance requirements while allowing for script customization.

Annotate your variables to have them appear as form fields when a user edits a script. These annotations allow variable values within a script to be changed easily by those with limited code familiarity.

Dynamic form annotations are available anywhere you can enter code in ScriptRunner, including the Script Console, Jobs, Listeners, Pre Hooks, Post Hooks, and Merge Checks.

For example, as a power user, you have created a script to assign reviewers for a pull request. This script is used across multiple repositories and projects, and you need to set different reviewers for each case. Instead of hardcoding the users to be used for reviewers for each case, you can now use a dynamic form annotation, meaning the users can be changed without needing to re-write the script. As well as being able to edit the script quickly, you can maintain the code in one centralized location. The dynamic form annotation shows the ‘reviewers’ variable as a form field:

The above example uses the following code:

An error occured

There is a problem with the file path provided or a failure to connect with Bitbucket. Check the File Path provided, Application Link for Bitbucket Data Center or the permissions of the app password for Bitbucket Cloud. Please contact your system administrator to do so.

The following dynamic form field types are available:

NameDescriptionTarget Type

User Picker

Field allowing user selection.

com.atlassian.bitbucket.user.ApplicationUser

Short Text

Field allowing a short text input.

String

Select List

Single-select list field.

String

Checkbox

A checkbox field.

Boolean

Project Picker

Field allowing project selection.

com.atlassian.bitbucket.project.Project

Repository PickerField allowing repository selection.com.atlassian.bitbucket.repository.Repository
Branch PickerField allowing branch selection.

com.onresolve.scriptrunner.bitbucket.branch.BranchWithRepository

Tag PickerField allowing branch selection.

com.onresolve.scriptrunner.bitbucket.tag.TagWithRepository

We are in the process of adding more dynamic form field types.

Create a Dynamic Form

  1. Click the Cog in the top ribbon, to open the Administration Overview page.

  2. Select Script Console under ScriptRunner.

  3. Write your new script in the Script field, annotating the variables you want users to provide. Annotating variables allows them to be edited depending on requirements when running the script. These variables show as editable fields above the Script Console.

Transforming an Existing Inline Script

To enable sharing of annotated scripts, all inline scripts must be saved as files.

  1. Navigate to your existing inline script, and add in required annotations.

  2. Copy the script.

  3. Use the Script Editor to open your Scripts Root folder.

  4. Select the folder in which you want to save the script, and click the Create New File icon.

  5. Enter a file name in the Add New Groovy File/Add New Groovy Folder window.

  6. Click Add.

  7. Paste your inline script into the file, and click Save. This script is now available as a file and can be shared with multiple Bitbucket users on the same instance.

Annotations

User Picker

Add a user picker field into your script.

An error occured

There is a problem with the file path provided or a failure to connect with Bitbucket. Check the File Path provided, Application Link for Bitbucket Data Center or the permissions of the app password for Bitbucket Cloud. Please contact your system administrator to do so.

User multi-pickers are also supported.

An error occured

There is a problem with the file path provided or a failure to connect with Bitbucket. Check the File Path provided, Application Link for Bitbucket Data Center or the permissions of the app password for Bitbucket Cloud. Please contact your system administrator to do so.

Short Text

Add a short text field to a script.

An error occured

There is a problem with the file path provided or a failure to connect with Bitbucket. Check the File Path provided, Application Link for Bitbucket Data Center or the permissions of the app password for Bitbucket Cloud. Please contact your system administrator to do so.

Select List

Add a single-select list with configurable options.

An error occured

There is a problem with the file path provided or a failure to connect with Bitbucket. Check the File Path provided, Application Link for Bitbucket Data Center or the permissions of the app password for Bitbucket Cloud. Please contact your system administrator to do so.

Multi-select lists are also supported.

An error occured

There is a problem with the file path provided or a failure to connect with Bitbucket. Check the File Path provided, Application Link for Bitbucket Data Center or the permissions of the app password for Bitbucket Cloud. Please contact your system administrator to do so.

Checkbox

Add a checkbox to a script.

An error occured

There is a problem with the file path provided or a failure to connect with Bitbucket. Check the File Path provided, Application Link for Bitbucket Data Center or the permissions of the app password for Bitbucket Cloud. Please contact your system administrator to do so.

Project Picker

Add a project picker to a script.

An error occured

There is a problem with the file path provided or a failure to connect with Bitbucket. Check the File Path provided, Application Link for Bitbucket Data Center or the permissions of the app password for Bitbucket Cloud. Please contact your system administrator to do so.

Project multi-pickers are also supported.

An error occured

There is a problem with the file path provided or a failure to connect with Bitbucket. Check the File Path provided, Application Link for Bitbucket Data Center or the permissions of the app password for Bitbucket Cloud. Please contact your system administrator to do so.

Repository Picker

Add a repository picker to a script.

An error occured

There is a problem with the file path provided or a failure to connect with Bitbucket. Check the File Path provided, Application Link for Bitbucket Data Center or the permissions of the app password for Bitbucket Cloud. Please contact your system administrator to do so.

Repository multi-pickers are also supported.

An error occured

There is a problem with the file path provided or a failure to connect with Bitbucket. Check the File Path provided, Application Link for Bitbucket Data Center or the permissions of the app password for Bitbucket Cloud. Please contact your system administrator to do so.

Branch Picker

Add a branch picker to a script.

An error occured

There is a problem with the file path provided or a failure to connect with Bitbucket. Check the File Path provided, Application Link for Bitbucket Data Center or the permissions of the app password for Bitbucket Cloud. Please contact your system administrator to do so.

Tag Picker

Add a tag picker to a script.

An error occured

There is a problem with the file path provided or a failure to connect with Bitbucket. Check the File Path provided, Application Link for Bitbucket Data Center or the permissions of the app password for Bitbucket Cloud. Please contact your system administrator to do so.

On this page