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

Pulumi CLI not found error when "versionSpec" is specified #64

Closed asehra closed 3 years ago

asehra commented 3 years ago

Describe the bug When the versionSpec input is configured to 3.0.0, the first run caches the cli, and the subsequent looks for the cli on PATH but fails.

To Reproduce Steps to reproduce the behavior:

  1. Configure a pulumi config task as below:
    - task: Pulumi@1
      displayName: Pulumi config
      env:
        AZURE_STORAGE_ACCOUNT: $(pulumiStateStorageAccount)
        AZURE_STORAGE_KEY: $(pulumiStateStorageAccountKey)
        PULUMI_CONFIG_PASSPHRASE: $(pulumiSecret)
        PULUMI_SELF_MANAGED_STATE_LOCKING: 1
      inputs:
        azureSubscription: '$(azureSubscription)'
        command: 'config'
        loginArgs: 'azblob://$(pulumiStateContainer)'
        stack: 'my-stack'
        versionSpec: '3.0.0'
        createStack: true
  2. Run the task. The first execution downloads the tool and caches it:
    
    Downloading: https://get.pulumi.com/releases/sdk/pulumi-v3.0.0-linux-x64.tar.gz
    Extracting archive
    /usr/bin/tar xC /azp/agent/_work/_temp/2f278ff1-a72c-49f7-9278-65e3e388xxxx -f /azp/agent/_work/_temp/44fa164e-c998-4f35-bbf3-10d64b65xxxx

Prepending PATH environment variable with directory: /azp/agent/_work/_temp/2f278ff1-a72c-49f7-9278-65e3e388xxxx/pulumi Caching tool: pulumi 3.0.0 x64 /azp/agent/_work/_temp/2f278ff1-a72c-49f7-9278-65e3e388xxxx/pulumi/pulumi version v3.0.0

3. Run the task again. This time the task looks for the tool in cache and finds it. It prepends a folder to path. But the task then runs a [`which`](https://github.com/pulumi/pulumi-az-pipelines-task/blob/51c5154d27c28012b9b5dc41f5de151a95234026/buildAndReleaseTask/index.ts#L60) command that is not able to find the cli on path and gives this output:

Found tool in cache: pulumi 3.0.0 x64 Prepending PATH environment variable with directory: /azp/agent/_work/_tool/pulumi/3.0.0/x64

[error]Pulumi CLI does not seem to be installed in your environment.


4. Removing `versionSpec` fixes it, as it doesn't look for the cached tool. 

**Expected behavior**
Adding the cache path to $PATH should have made the cli available to the task. 
praneetloke commented 3 years ago

Thanks for reporting this, @asehra. I am suspecting that the directory added to the PATH from the tool cache is perhaps encapsulated in another directory. If you could please add a command-line task after the initial Pulumi task step and see what is under /azp/agent/_work/_tool/pulumi/3.0.0/x64? That would help diagnose this.

praneetloke commented 3 years ago

The fix for this is now available in v1.0.10.