# Pipeline template array variable

**URL:** https://drone.discourse.group/t/pipeline-template-array-variable/11602
**Category:** Drone Support
**Created:** [February 2, 2022, 10:15am UTC](https://drone.discourse.group/t/pipeline-template-array-variable/11602 "2022-02-02T10:15:13Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![beniamin](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/beniamin/32/3078_2.png) [@beniamin](https://drone.discourse.group/u/beniamin)
#### Post date: [February 2, 2022, 10:15am UTC](https://drone.discourse.group/t/pipeline-template-array-variable/11602/1 "2022-02-02T10:15:13Z")

</div>

We have many microservices written with PHP/Symfony. The pipeline for most of them looks like:

1. build the image
2. prepare the image for testing(install phpunit, etc)  
3…7. Run some tests in parallel(steps may differ between microservice)
3. push the image to registry

I want to know if there is any possibility to create steps from 3-7 dinamically from a list of `{name, command}` using pipeline templates?  
I am thinking at something like:

```auto
kind: template
load: plugin.yaml
data:
  name: name
  image: image
  testSteps:
    - name: unit
      commmand: "phpunit --filter Unit"
    - name: security
      command: "bin/console symfony:security-check"
    ...

```

---

<div class="post-metadata">

### Author: ![Eoin\_Mcafee](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/eoin_mcafee/32/3006_2.png) [@Eoin\_Mcafee](https://drone.discourse.group/u/Eoin_Mcafee)
#### Post date: [February 3, 2022, 10:31am UTC](https://drone.discourse.group/t/pipeline-template-array-variable/11602/2 "2022-02-03T10:31:26Z")

</div>

Hey @beniamin

At the minute there’s no support for the above.

Cheers,  
Eoin

---

<div class="post-metadata">

### Author: ![drone](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/drone/32/6956_2.png) [@drone](https://drone.discourse.group/u/drone)
#### Post date: [February 3, 2022, 2:43pm UTC](https://drone.discourse.group/t/pipeline-template-array-variable/11602/3 "2022-02-03T14:43:34Z")

</div>

@Eoin_Mcafee looping through arrays is supported by the Go template engine. Would the below template work with the sample that beniamin provided?

```auto
kind: pipeline
type: docker
name: default

steps:
{{range .input.testSteps}}
  - name: {{.name}}
    image: php
    commands:
    - {{.command}}
{{end}}

  - name: publish
    image: plugins/docker
    settings:
      repo: {{ .input.image }}

```

---

<div class="post-metadata">

### Author: ![beniamin](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/beniamin/32/3078_2.png) [@beniamin](https://drone.discourse.group/u/beniamin)
#### Post date: [February 4, 2022, 6:45pm UTC](https://drone.discourse.group/t/pipeline-template-array-variable/11602/4 "2022-02-04T18:45:06Z")

</div>

@bradrydzewski your example seems to work.  
Is there any way to “print” the compiled(final) pipeline?

---

<div class="post-metadata">

### Author: ![drone](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/drone/32/6956_2.png) [@drone](https://drone.discourse.group/u/drone)
#### Post date: [February 4, 2022, 10:15pm UTC](https://drone.discourse.group/t/pipeline-template-array-variable/11602/5 "2022-02-04T22:15:43Z")

</div>

@beniamin this feature does not currently exist. We brainstormed adding a CLI command and API endpoint to generate yaml files from templates, for testing purposes. This is definitely something we are interested in, but not something we are actively working on.
