Configure agent environment variables

2 minute readReference
On this page

You can configure an agent environment variable with a CloudBees CD/RO server-side property instead of in the agent’s agent/wrapper.conf file. You can create these custom properties in individual zones, resources, or resource pools under a custom property sheet, named ec_environment_variables.

The ec_environment_variables property sheet does not exist for these objects at installation time: zones, resources, or resource pools. Therefore, it may be necessary to create this property sheet to add your custom properties.
  • Environment variables defined in wrapper.conf are defined for both the process environment of step commands run by the agent and for the agent process itself.

  • If a particular environment variable is defined in both wrapper.conf and on the ec_environment_variables property sheet, then the agent process sees the value defined in wrapper.conf, but the step commands only sees the value defined in the property sheet.

Environment variables defined on the resource level have the highest priority and may overwrite any other variables because they are the last to be applied. The following order applies to environment variables:

  1. resource pool

  2. zone

  3. resource

Benefits include:

  • Agent environment variables can be centrally managed by the CloudBees CD/RO server.

  • Environment variables can be set at the zone level for all resources from this zone or at the resource level for individual agents. The settings at the resource level take precedent over the settings at the zone level.

  • Agent restart is not required for the new ec_environment_variables property sheet settings to take effect, which is required when applying the changes in the agent/wrapper.conf file.

  • Two or more resources can be created based on the same agent by defining different environment variables. You can then use them independently by the executed job steps on the agent.

As a best practice, use the ec_environment_variables approach rather than the wrapper.conf approach to avoid introducing environment variables into the agent process itself and to avoid having to edit files on the agent and restart the agent, as noted.

For more information about properties, refer to Properties.

Examples

For example, a customer has machine agent-b installed with one CloudBees CD/RO agent that has access to the public internet via proxy, only. To specify programs such as curl or wget to use a proxy, set special environment variables as a property under the appropriate CloudBees CD/RO server zones or resources:

  • HTTP proxy for all agents in the same zone, zone-a: /zones/zone-a/ec_environment_variables/http_proxy=http://user:password@your-proxy-ip-address:port/

  • HTTPS proxy for an individual resource, agent-b: /resources/agent-b/ec_environment_variables/https_proxy=http://user:password@your-proxy-ip-address:port/