Jenkins Plugin – withFolderProperties

The Jenkins plugin “withFolderProperties” allows users to set folder-level properties that can be inherited by all the jobs within a specific folder. This plugin allows users to set global properties, such as environment variables or build parameters, at the folder level, and have them automatically applied to all the jobs within that folder.

This can be useful for situations where multiple jobs within a folder share common properties or configurations. Instead of having to set these properties individually for each job, they can be set at the folder level, and inherited by all the jobs within that folder.

The plugin also allows users to override properties at the job level, if needed. This allows for flexibility in managing properties and configurations, while still maintaining consistency across jobs within a folder.

Additionally, withFolderProperties plugin also allows users to have a more fine-grained control on how the folders are organized, users can create folders with different properties, and only the jobs in that folder will inherit those properties, this allows for better scalability and organization within Jenkins.

The withFolderProperties step in a Jenkins pipeline script is used to set the properties of a Jenkins folder for the duration of the pipeline. This step allows you to access and use the properties of a Jenkins folder within your pipeline script.

For example, you can use withFolderProperties to access environment variables that are set at the folder level, which can then be used in the pipeline script. Here is an example:

node {

    withFolderProperties {

        echo "Folder property FOO is: ${env.FOO}"

    }

}

In this example, the withFolderProperties step is used in a scripted pipeline (older version) to set the environment variable FOO for the current pipeline, and the echo function is used to print the value of FOO to the console.

It is important to note that the folder properties set by withFolderProperties only apply to the scope of the block of code where withFolderProperties is used, and will not affect the entire pipeline. More information on this plugin can be found on here

In conclusion, the withFolderProperties plugin is a useful tool for managing properties and configurations for jobs within a folder in Jenkins, it allows for the inheritance of properties at the folder level and the flexibility of overriding at the job level, it also gives a better scalability and organization to the jobs.