Jenkins system properties refer to a set of global variables that can be used in various parts of the system. These system properties can be used to unlock a set of “hidden” features in Jenkins, allowing you to get access to a few experimental features.
In this tutorial, we will learn how to use and access various Jenkins System properties either via the Jenkins user interface or a specific argument on the command line.
Note that system properties are different from environment variables specific to a particular operating system and can be set and accessed differently.
Using Jenkins System Properties
To use Jenkins System Properties, we use the -D argument in the Jenkins command line when starting Jenkins.
The syntax for enabling Jenkins system properties is as shown:
Ensure to include all the arguments before the -jar argument; otherwise, the Jenkins-CLI will ignore them.
An example command is as shown:
Another method we can use to access and set system properties in Jenkins is using the Jenkins Script console.
Example 1
The following example shows how to use the Jenkins script console to set the value for the Client-side HTTP CLI ping interval in milliseconds.
The command above should set the default ping interval to 3000 milliseconds.
It is good to note that the Jenkins server will reset the system properties to default when the server reboots. You can permanently set the system properties values by creating a Jenkins startup script.
This will force Jenkins to load the startup script upon launch.
To create a startup script in Jenkins:
Locate the Jenkins home directory by running the command:
For example, if your Jenkins home is set to /var/lib/jenkins. You can add a file called init.groovy.d
To discover the various system properties, you can enable or configure in your Jenkins server, check the resource below:
https://www.jenkins.io/doc/book/managing/system-properties/
Conclusion
Jenkins system properties are global variables that can be used to configure various aspects of the Jenkins system.
We can configure the Jenkins system properties using the -D flag in the Jenkins CLI or the script console on the Jenkins Dashboard.
System properties help control Jenkins’ behavior and create custom configurations for jobs and projects. It is good to note that enabling or changing the configuration of various system properties can come with high costs, such as security and resource. Consider the impact of each property before making any modifications.