Agent environment variables

On this page

Set an agent environment variable with a CloudBees CD/RO server-side property instead of in the agent’s agent/wrapper.conf file. These properties can be created under zones or resources objects in the custom ec_environment_variables property sheet.

The ec_environment_variables property sheet may not exist, so it must be created under zones or resources objects.
  • 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 itself sees the value defined in wrapper.conf and step commands see the value defined in the property sheet.

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 individiual agents. The settings at the resource level take precedent over the settings at the zone level.

  • Agent restart is not required in order 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. Then use them independently by the executed job steps on the agent.

As best practice, use the ec_environment_variables approach in preference to 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 further information about properties, see Properties.

Examples

For instance, 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, wget, and so on 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/