pulumi / pulumi-az-pipelines-task

Azure Pipelines task extension for running Pulumi apps.
https://marketplace.visualstudio.com/publishers/pulumi
Apache License 2.0
27 stars 19 forks source link

`createStack:true` doesn't work when used with fully qualified stack names #53

Closed asizikov closed 3 years ago

asizikov commented 3 years ago

Describe the bug

createStack:true should create a new stack when it doesn't exist, however it doesn't work when I use a fully qualified stack name.

To Reproduce Steps to reproduce the behavior:

  1. Create an Azure Pipiline with a task like this:
                - task: Pulumi@1
                  displayName: 'Create new Stack if needed'
                  inputs:
                    azureSubscription: $(azureSubscriptionName)
                    command: 'stack'
                    args: 'select $(stackName)'
                    cwd: 'infra/'
                    stack: '$(stackName)'
                    createStack: true
  2. Run the pipeline

When the $stackName variable contains the short name for the stack it works ok, however when I use a fully qualified name organization/project/stack-name my pipeline failes.

In logs I can see

pulumi stack select my-org-redacted/infra/does-not-exist
error: no stack named 'does-not-exist' found

Expected behavior

A new stack should be created

Screenshots If applicable, add screenshots to help explain your problem.

Additional context

This feature was introduced in https://github.com/pulumi/pulumi-az-pipelines-task/pull/36

In particular this line: https://github.com/pulumi/pulumi-az-pipelines-task/blob/db5d6c9dc6c42da75eb27fd3a91267f91b9b4f38/buildAndReleaseTask/pulumi.ts#L50

const errMsg = `no stack named '${pulStack}' found`;

I believe the the comparison is made with the full name, but the actual error message contains a short name. Hence there is no match and the pipeline fails.

praneetloke commented 3 years ago

@asizikov thank you for taking the time to submit the bug report! Appreciate the details. The current way of creating a stack if one doesn't exist was always just a workaround to using the CLI's built-in way to do it. Ideally, I'd like to update the task extension to simply add the flag to the stack select command if the user wishes to create a stack. Also see https://github.com/pulumi/pulumi-az-pipelines-task/issues/38.