Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 4. Configuring Your Jenkins Server > Configuring Global Properties

4.4. Configuring Global Properties

The Global Properties (see Figure 4-3) section lets you define variables that can be managed centrally but used in all of your build jobs. You can add as many properties as you want here, and use them in your build jobs. Jenkins will make them available within your build job environment, so you can freely use them within your Ant and Maven build scripts. Note that you shouldn’t put periods (“.”) in the property names, as they won’t be processed correctly. So ldapserver or ldap_server is fine, but not ldap.server.

Figure 4-3. Configuring environment variables in Jenkins


There are two ways you typically use these variables. Firstly, you can use them directly in your build script, using the ${key} or $key notation (so ${ldapserver} or $ldapserver in the example give above. This is the simplest approach, but means that there is a tight coupling between your build job configuration and your build scripts.

If your script uses a different property name (one containing dots, for example), you can also pass the value to your build script in the build job configuration. In Figure 4-4 we pass the ldapserver property value defined in Figure 4-3 to a Maven build job. Using the -D option means that this value will be accessible from within the build script. This is a flexible approach, as we can assign the global properties defined within Jenkins to script-specific variables in our build scripts. In Figure 4-4, for example, the ldapserver property will be available from within the Maven build via the internal ${ldap.server} property.

Figure 4-4. Using a configured environment variable


  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint