This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.3.9. Build environments
As with pod environment variables, build environment variables can be defined in terms of references to other resources or variables using the Downward API. There are some exceptions, which are noted.
You can also manage environment variables defined in the BuildConfig
with the oc set env
command.
Referencing container resources using valueFrom
in build environment variables is not supported as the references are resolved before the container is created.
3.9.1. Using build fields as environment variables 复制链接链接已复制到粘贴板!
You can inject information about the build object by setting the fieldPath
environment variable source to the JsonPath
of the field from which you are interested in obtaining the value.
Jenkins Pipeline strategy does not support valueFrom
syntax for environment variables.
Procedure
Set the
fieldPath
environment variable source to theJsonPath
of the field from which you are interested in obtaining the value:env: - name: FIELDREF_ENV valueFrom: fieldRef: fieldPath: metadata.name
env: - name: FIELDREF_ENV valueFrom: fieldRef: fieldPath: metadata.name
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.9.2. Using secrets as environment variables 复制链接链接已复制到粘贴板!
You can make key values from secrets available as environment variables using the valueFrom
syntax.
Procedure
To use a secret as an environment variable, set the
valueFrom
syntax:Copy to Clipboard Copied! Toggle word wrap Toggle overflow