Skip to content

It is possible to use a context's variables in a task? #94

@russellseymour

Description

@russellseymour

I am working with taskctl to simplify some builds and to use PowerShell as my context for the task. I have sucessfully created a context that allows me to do this.

From the docs, I had thought that I would be able to set some variables in the context and then use them in the task which uses that context, like so:

contexts:
  powershell:
    executable:
      bin: pwsh
      args:
        - -NoProfile
        - -Command
    variables:
      test_arguments: "-v q /p:CollectCoverage=true /p:CoverletOutputFormat=opencover"

tasks:

  test:unittest:
    context: powershell
    description: Perform unit tests
    command:
      - build/scripts/Invoke-DotNetTests.ps1 -arguments {{ .test_arguments }}
    env:
      pattern: "*UnitTests"

However, when I run this i get the error message:

time="2021-11-12 14:59:45" level=info msg="Running task test:unittest..."
time="2021-11-12 14:59:45" level=info msg="test:unittest finished. Duration 498.7µs"
time="2021-11-12 14:59:45" level=fatal msg="task test:unittest failed: template: interpolate:1:76: executing \"interpolate\" at <.test_arguments>: map has no entry for key \"test_arguments\""

Does this mean it is not possible to interpolate variables set in the context?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions