Environment Variable and Parameter names in CloudBees CI

Last Reviewed:2025-02-18()
2 minute readKnowledge base

Issue

  • When my Pipeline input parameter name contains a hyphen (-) and I try to build it on a Linux agent, the name is not parsed correctly, potentially causing the build to fail.

Context

Environment variables are injected into CloudBees CI and Jenkins builds from different sources. For instance, Pipeline and Freestyle parameters are passed as environment variables to the agent building the steps. Another example would be the build context data like the cause of the build or the URL of the build, that are also injected as environment variables.

Because they are passed in the form name=value, they shall not contain equal characters (=). By default, the controller does not perform any validation on the variable and parameter names, it just passes them down to the OS. This means that the allowed characters in them will depend on the underlying OS.

Overriding a system environment variable can lead to unexpected build behaviours and undesired outcomes. Administrators should review the usage of environment variables in their jobs and plugins. Moreover, not all scripts and script interpreters commonly invoked during builds are able to parse any variable name, so administrators are encouraged to filter or sanitize environment variable values.

Resolution

To ensure that variables are portable across systems, it is recommended to use expressions that consist of underscores (_), digits (0-9), and latin alphabet characters (a-z,A-Z), and that do not begin with a number. By convention, names for environment variables and job input parameters are specified in capital case, with individual words separated by underscores. You can, however, specify any legitimate variable name using lower case characters. Note that environment variables and parameters are also case sensitive.

Tested product/plugin versions

  • CloudBees CI on modern cloud platforms - managed controller - version 2.492.1.3