Azure-pipelines-tasks: workingDirectory not respected for Azure PowerShell task

Created on 29 Nov 2019  路  13Comments  路  Source: microsoft/azure-pipelines-tasks

Required Information

Entering this information will route you directly to the right team and expedite traction.

Question, Bug, or Feature?
Type: Bug

Enter Task Name: AzurePowerShellV4

Environment

  • Server - Azure Pipelines

  • Agent - Hosted or Private:

    • If using Hosted agent, provide agent queue name:

Issue Description

Setting the WorkingDirectory in the UI will not cause the script to be executed from that directory

Create the following task
steps:

  • task: AzurePowerShell@4
    displayName: Dir
    inputs:
    azureSubscription: 'My subscription'
    ScriptType: InlineScript
    Inline: dir
    azurePowerShellVersion: LatestVersion
    workingDirectory: '$(System.DefaultWorkingDirectory)/mydirectory

The concents of mydirectory will not be listed

Release AzurePowerShell bug bug

All 13 comments

@stilren I am not sure if I understand your question perfectly. However, from what I could understand running dir from your 'mydirectory' should list the contents of that directory and not the directory itself. If this did not solve it can you share the exact expected v/s real output logs here? Thanks!

Yeah sorry if that was unclear - I am expecting the contents of the directory to be displayed but its not

@stilren I am sorry but I am not able to repro the issue. The contents of the directory are getting listed. Can you please share the directory structure and pipeline logs with system.debug set as true.

@stilren Can you please confirm if you're still facing the issue?

Please comment to re-open if you're still facing the issue.

Hello,

I am experiencing the same behavior with the PowerShell task. Setting "Working Directory" under Advanced is not applied.
Maybe worth to note, that my path contains '[' and ']', e.g. '$(System.DefaultWorkingDirectory)_CompanyApp-UWP [Release-Experimental-E2E]\drop\CompanyApp_$(Build.BuildNumber)'_Test\'.
There is no error in the console output, only that directory is set to 'C:\' and not to the specified under Working Directory.

@stilren Please use the latest version of AzurePowerShell task i.e. V5, and check if the working directory works for you there

@kristianpinke @stilren Let me know if you got unblocked using latest version of AzurePowerShell

@kristianpinke @stilren Can anyone of you please let me know, if you got unblocked or not ?

@20shivangi Hello, I am sorry but I cannot try it out. I realized that this thread is about the "Azure PowerShell" task. In my case, the problem occurs with the "PowerShell" task. In that task, the newest version is 2.*
I am not able to use "Azure PowerShell" tasks as I do not have a proper Azure subscription and I am only part of the DevOps team in my organization.
Would it be possible to fix the same for the "PowerShell" task?

@kristianpinke Our team does not own PowerShell task, you can raise it as a separate github issue.

Closing this issue. Feel free to reopen if you are facing the issue. We will be happy to help you

For those reading this thread as I did. WorkingDirectory did NOT work in V4, but it DOES work on V5.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Mardoxx picture Mardoxx  路  3Comments

montebhoover picture montebhoover  路  3Comments

timfish picture timfish  路  3Comments

alexszilagyi picture alexszilagyi  路  3Comments

MichaelWhiteCodingForFun picture MichaelWhiteCodingForFun  路  3Comments