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