curtank
curtank

Reputation: 710

how to generate "for loop" in YAML file

suppose we have the following YAML

a:
  - s1: p
  - s2: p
  - s3: p
  - s4: p

is there a syntax using for loop to generate this YAML file

like:

enum: [s1,s2,s3,s4]
a:
for t in enum:
  -t:p

writing a script is a way to do this. Is this feasible?

Upvotes: 9

Views: 59026

Answers (2)

Sid
Sid

Reputation: 5365

I believe you are trying something like yaml template in azure devops : Try something like:

${{each img in parameters.images}}:
      ${{img.key}}:

Upvotes: 4

Nikolas
Nikolas

Reputation: 61

There is no way to shorten a YAML file the way you are planning to do.

A solution would be a script that interprets the file and shortens it the way you like, which would only be usable for readability.

Upvotes: 6

Related Questions