Azure-pipelines-tasks: Powershell task does not expose variables to a task group

Created on 1 Feb 2019  路  7Comments  路  Source: microsoft/azure-pipelines-tasks

Environment

  • Server - Azure Pipelines
  • Agent - Hosted VS2017

Issue Description

I am trying to extract a powershell task into a task group in order to reuse the script and I wanted to pass some parameters as variables but it seems the pipeline doesn't identify those as task group variables:

image

Nothing happens in this case. The _command line_ task has the same problem. I tried to add another non-cmd task and there it worked as expected. This issue might be related to #8737 but is still slightly different

Release enhancement

Most helpful comment

Found a strange workaround. If you use $(some text) in your powershell script then the some text is exposed as a variable. Like this

Select-String -Pattern "$(Include Filter)" -Quiet

And the Include Filter variable pops up and I can use it from a parent task.

All 7 comments

Found a strange workaround. If you use $(some text) in your powershell script then the some text is exposed as a variable. Like this

Select-String -Pattern "$(Include Filter)" -Quiet

And the Include Filter variable pops up and I can use it from a parent task.

Looks like an issue with task groups ... routing

We only consider any $(Var) format and parameterize it as part of task group.

Hit this today, have an environment variable in a task within a task group with a value in format $(Var) and it does not appear as a parameter. If I enter the variable in another part of the task, such as script arguments it does appear. So seems specific to environment variables.

Ran into the same thing today (Azure Pipelines latest (Sprint 165)).

If you define a variable in Control Options > Custom Condition, it's not picked up by the Create Task Group dialog.

I tried both syntaxes: eq('$(PublishArtifacts)', 'true') and eq(variables['PublishArtifacts'], 'true') - neither worked.

Edit: The workaround by @stukalin works great, but having an extra step in the process is less than desirable.

This issue is stale because it has been open for 180 days with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days

Still an issue - bad bot!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

HenrikStanley picture HenrikStanley  路  3Comments

MichaelWhiteCodingForFun picture MichaelWhiteCodingForFun  路  3Comments

MikahB picture MikahB  路  3Comments

jared-hexagon picture jared-hexagon  路  3Comments

montebhoover picture montebhoover  路  3Comments