Reusing enum type definitions across multiple commands/jobs in a single `config.yml`

I have a config.yml that has a number of commands/jobs that accept a parameter specifying the environment against which the job should run. These all define this parameter as an enumeration over the possible environments:

    parameters:
      environment:
        type: enum
        enum: ["env-a", "env-b", "env-c", "env-d" ...]

The problem with this approach is that there doesn’t seem to be a way to share the definition of the enumeration type across the various jobs. I’ve wound up with the same enumeration definition repeated again and again throughout the config.yml file. (Which makes it difficult to reliably edit and all the other assorted problems that are associated with non-“DRY” code.)

My question is whether or not there’s an accepted way within 'standard config.yml` to reuse this sort of definition? (Maybe a YAML anchor or similar?)

YAML anchors are supported within config.yml scripts so they can be used for such a task.

Other options include

  • passing a parameter to the project, but this complicates the repo integration as you have to create
    a way to cause the script to be executed via API calls or the continuation ORB/process.
  • project-level or account-level environment variables.
  • external key-value stores.

All of which can help you maintain ‘DRY’ principles depending on the scope of the value you are trying to maintain, at the cost of additional complexity.

1 Like

@rit1010 Thank you… The Yaml Anchor approach seems to be working well.