Skip to content

Scriptlets Supporting Active Choices Parameters

Ioannis K. Moutsatsos edited this page Apr 12, 2018 · 3 revisions

Scriptlets returning a list or a map

The following scriptlets are used to display dynamic parameter options when used with Active Choices Jenkins parameters. Active Choices parameters generate dynamic options from groovy scripts or groovy scriptlets and typically require that the scripts return a groovy list or map structure.

Displays a list of build artifacts from a specified build of a Jenkins project.

  • The scriptlet returns a map in the form of artifact_URL=artifact_Name.
  • You can filter the artifacts by extension
  • The user makes selections on human-readable artifact names
  • The Active Choice selected artifacts are returned as URLs to the artifacts
  • Returns a map of the server job names keyed to the folder/job name
  • The user makes selections on human-readable job names

Returns a list of human readable names for the builds of a specified Jenkins project. The list can act as a surrogate 'Run-Type' Jenkins parameter, but with the following advantages:

  • it can return builds within a user defined build number range
  • it has a customizable format
  • it can return builds with a certain build status (the default is SUCCESS)

Identifies a file extension and returns a fileType label.

Sometimes you want to autodetect a file type. Given a file extension, the scriptlet will auto-select one of several predefined options such as IMAGE, BINARY, TEXT, HTML, CSV_TABLE, TSV_TABLE. By adding new options to the extensions arrays, additional file types can be detected. Note that the user can override the auto-detected file type

Returns a list with the values of a Java-style property stored in a static properties file. Static properties files are served from the Jenkins userContent/properties folder

A single property value will generate a single Active Choice option value, while a comma separated value list will generated multiple option values.

Returns a map of build references (for one or more Jenkins jobs) within a specified build number range. Used in combination with Active Choices parameters it provides a human readable display value backed by a standardized reference build represented by the map key in the format JOB_NAME#BUILD_NUMBER.

Similarly to the getBuildByNumber_scriptlet (above)

  • it can return builds within a user defined build number range
  • it has a customizable format
  • it can return builds with a certain build status (the default is SUCCESS)

In addition

  • it can display user-friendly choice options while internally returning the map key as a build parameter. The map key is in a standardized build reference format (JOB_NAME#BUILD_NUMBER)

The JOB_NAME#BUILD_NUMBER format is used as the standard input parameter format to other scriptlets to generate additional build information

See here for details on a UC_helper_GetBuildsByNumAsMap usage example.