Groovy Postbuild Plugin And CloudBees Folders Plugin

Article ID:204755470
1 minute readKnowledge base

Issue

Using the Groovy Postbuild Plugin in Jenkins Environment that utilizes Folders

Environment

CloudBees Jenkins Enterprise

Resolution

When jobs are arranged using folders they are accessible via Groovy Postbuild scripts as shown in the examples below.

Accessing a specific job that is located in folder_name/folder_name/folder_name.

job1 = hudson.model.Hudson.instance.getItem("folder\_name").getItem("folder\_name").getItem("folder\_name")

Searching for an item inside of a folder.

jenkins.model.Jenkins.instance.getItemByFullName("folder\_name/folder\_name/folder\_name");

The following link has more information about the methods that are available to use: https://javadoc.jenkins-ci.org/jenkins/model/Jenkins.html

This article is part of our Knowledge Base and is provided for guidance-based purposes only. The solutions or workarounds described here are not officially supported by CloudBees and may not be applicable in all environments. Use at your own discretion, and test changes in a safe environment before applying them to production systems.