Authoring devfilesDefining variables

Authoring devfiles

Defining variables

The variables object is a map of variable name-value pairs that you can use for string replacement in the devfile. Variables are referenced using the syntax {{variable-name}} to insert the corresponding value in string fields in the devfile.

You can define variables at the top level of the devfile or in the parent object. String replacement with variables cannot be used for:

  • schemaVersion, metadata, or parent source
  • Element identifiers such as,,, and
  • References to identifiers, for example, when binding commands by name to events, when specifiying a command's component, or when specifying the volume mount name for a container
  • String enumerations such as command group.kind or endpoint.exposure


  1. Add a variable definition at the top level in your devfile:

    schemaVersion: 2.2.0
      name: java-maven
      version: 1.1.1
      javaVersion: 11
  2. Reference the variable by name later in the devfile:

    - name: tools

If you reference a variable that is not defined, a non-blocking warning is issued.