Skip to content

Templating, command lists and file globs #82

@twhiston

Description

Maybe i just am not looking at this from the right angle but I was trying to use the templating to generate a series of commands that can be run based on the input variables. For example lets say i have a list of variables for dockerfile versions/contexts

NS: tomwhiston
REPO: my-project
NAME: my-project
VERSIONS: |
  prod
  prodv3-builder
  prodv3-runtime
  test-base
  test

and the following task

build:
  cmds:
    - |
      {{- range $i, $version := .VERSIONS | splitLines -}}
         {{ if $version }}docker build -t "{{ $.NS }}/{{ $.REPO }}:{{ $version }}" ./context/{{ $version | replace "-" "/" }}{{ end }}
      {{ end -}}

Currently this task will always succeed, even if, for example, one of the contexts does not exist. So how would one go about implementing something like this, where any command that fails will abort operation, and without having a lot of calls to a task and setting specific vars to pass?
ie not

- task: build
  vars: {NS: "tomwhiston", REPO: "my-project", VERSION: "prod" }

Ideally the outcome I would like is that if I add a new context I simple name it in the vars list and run the commands unaltered.
If this is not possible currently would you be interested in such a feature being added?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions