Description
New issue checklist
- I searched for existing GitHub issues
- I read pipeline troubleshooting guide
- I checked how to collect logs
Task name
AzureFileCopy
Task version
5.231.2
Issue Description
When running the AzureFileCopy task in a self hosted agent it is failing with a You cannot call a method on a null-valued expression
exception.
Looking at the debug logs it is failing at this point:
##[debug]at CleanUp-PSModulePathForHostedAgent, C:\azp\agent\_work\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\5.231.2\Utility.ps1: line 1368
##[debug]at <ScriptBlock>, C:\azp\agent\_work\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\5.231.2\AzureFileCopy.ps1: line 69
Remoting to the container to look at that file, the stack is pointing to the CleanUp-PSModulePathForHostedAgent
method
function CleanUp-PSModulePathForHostedAgent {
# Clean up PSModulePath for hosted agent
$azureRMModulePath = "C:\Modules\azurerm_2.1.0"
$azureModulePath = "C:\Modules\azure_2.1.0"
$newEnvPSModulePath = $env:PSModulePath
if ($newEnvPSModulePath.split(";") -contains $azureRMModulePath) {
$newEnvPSModulePath = (($newEnvPSModulePath).Split(";") | ? { $_ -ne $azureRMModulePath }) -join ";"
write-verbose "$azureRMModulePath removed. Restart the prompt for the changes to take effect."
}
else {
write-verbose "$azureRMModulePath is not present in $newEnvPSModulePath"
}
if ($newEnvPSModulePath.split(";") -contains $azureModulePath) { <-- **************** this line ****************
$newEnvPSModulePath = (($newEnvPSModulePath).Split(";") | ? { $_ -ne $azureModulePath }) -join ";"
write-verbose "$azureModulePath removed. Restart the prompt for the changes to take effect."
}
else {
write-verbose "$azureModulePath is not present in $newEnvPSModulePath"
}
if (Test-Path "C:\Modules\az_*") {
$azPSModulePath = (Get-ChildItem "C:\Modules\az_*" -Directory `
| Sort-Object { [version]$_.Name.Split('_')[-1] } `
| Select-Object -Last 1).FullName
Write-Verbose "Found Az module path $azPSModulePath, will be used"
$env:PSModulePath = ($azPSModulePath + ";" + $newEnvPSModulePath).Trim(";")
}
}
We are setting the AZP_AGENT_CLEANUP_PSMODULES_IN_POWERSHELL
environment variable to true based on comments this this issue: #17708 as we were getting the same error in that issue when trying to run powershell tasks as them.
This is the minimal yaml that we've got reproducing this issue, where it creates a stub files & then tries to copy it using the AzureFileCopy
task:
steps:
- task: PowerShell@2
displayName: List env vars and create stub file
inputs:
targetType: 'inline'
script: |
ls env:* | sort name | ft -AutoSize
Write-Host "set test data to - $($env:PIPELINE_WORKSPACE)/drop/test.manifest"
New-Item -ItemType Directory -Path "$($env:PIPELINE_WORKSPACE)/test/" -ErrorAction SilentlyContinue
'{"test":2}' > "$($env:PIPELINE_WORKSPACE)/test/test.manifest"
- task: AzureFileCopy@5
displayName: test copy
inputs:
SourcePath: $$(Pipeline.Workspace)/test/*.manifest
azureSubscription: ${{ parameters.azureSubscription }}
Destination: AzureBlob
storage: teststorageaccount
ContainerName: buildtest
AdditionalArgumentsForBlobCopy: --overwrite true
We've tried disabling this by wrapping just the AzureFileCopy
with tasks that disable/enable the AZP_AGENT_CLEANUP_PSMODULES_IN_POWERSHELL
, but this leads to the same Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member AuditToString is already present
error again
- script: |
echo "##vso[task.setvariable variable=AZP_AGENT_CLEANUP_PSMODULES_IN_POWERSHELL]false"
- task: AzureFileCopy@5
displayName: test copy
inputs:
SourcePath: $$(Pipeline.Workspace)/test/*.manifest
azureSubscription: ${{ parameters.azureSubscription }}
Destination: AzureBlob
storage: teststorageaccount
ContainerName: buildtest
AdditionalArgumentsForBlobCopy: --overwrite true
- script: |
echo "##vso[task.setvariable variable=AZP_AGENT_CLEANUP_PSMODULES_IN_POWERSHELL]true"
Starting: test copy
==============================================================================
Task : Azure file copy
Description : Copy files to Azure Blob Storage or virtual machines
Version : 5.231.2
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/azure-file-copy
==============================================================================
##[error]The following error occurred while loading the extended type data file: Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member AuditToString is already present.
Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member AccessToString is already present.
Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member Sddl is already present.
Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member Access is already present.
Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member Group is already present.
Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member Owner is already present.
Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member Path is already present.
##[error]The 'ConvertTo-SecureString' command was found in the module 'Microsoft.PowerShell.Security', but the module could not be loaded. For more information, run 'Import-Module Microsoft.PowerShell.Security'.
Finishing: test copy
The docker container we are using to build the agents on is fairly basic, we're only pre-installing the Az
module. All the other tasks in the pipelines are running fine.
Dockerfile:
FROM mcr.microsoft.com/dotnet/sdk:8.0-windowsservercore-ltsc2019
USER ContainerAdministrator
RUN powershell -Command \
Install-PackageProvider -Name Nuget -Force -Verbose; \
Install-Module -Name Az -RequiredVersion 11.1.0 -Force -Scope AllUsers -Verbose;
RUN pwsh -Command \
Install-Module -Name Az -RequiredVersion 11.1.0 -Force -AllowClobber -Scope AllUsers -Verbose;
ENV AZP_AGENT_CLEANUP_PSMODULES_IN_POWERSHELL=true
USER ContainerUser
WORKDIR /azp
COPY start.ps1 .
CMD pwsh .\start.ps1
Environment type (Please select at least one enviroment where you face this issue)
- Self-Hosted
- Microsoft Hosted
- VMSS Pool
- Container
Azure DevOps Server type
dev.azure.com (formerly visualstudio.com)
Azure DevOps Server Version (if applicable)
No response
Operation system
Windows 11
Relevant log output
##[debug]Caught exception from task script.
##[debug]Error record:
##[debug]C:\azp\agent\_work\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\5.231.2\AzureFileCopy.ps1 : You cannot call a method on a null-valued expression.
##[debug]At line:1 char:1
##[debug]+ . 'C:\azp\agent\_work\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b ...
##[debug]+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
##[debug] + CategoryInfo : InvalidOperation: (:) [AzureFileCopy.ps1], RuntimeException
##[debug] + FullyQualifiedErrorId : InvokeMethodOnNull,AzureFileCopy.ps1
##[debug]
##[debug]Script stack trace:
##[debug]at CleanUp-PSModulePathForHostedAgent, C:\azp\agent\_work\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\5.231.2\Utility.ps1: line 1368
##[debug]at <ScriptBlock>, C:\azp\agent\_work\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\5.231.2\AzureFileCopy.ps1: line 69
##[debug]at <ScriptBlock>, <No file>: line 1
##[debug]at <ScriptBlock>, <No file>: line 22
##[debug]at <ScriptBlock>, <No file>: line 18
##[debug]at <ScriptBlock>, <No file>: line 1
##[debug]Exception:
##[debug]System.Management.Automation.RuntimeException: You cannot call a method on a null-valued expression.
##[debug] at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
##[debug] at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
##[debug] at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
##[debug] at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
##[debug] at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
##[debug] at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
##[debug] at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess)
##[debug] at System.Management.Automation.PSScriptCmdlet.DoEndProcessing()
##[debug] at System.Management.Automation.CommandProcessorBase.Complete()
Full task logs with system.debug enabled
2024-01-08T18:21:41.2472266Z ##[debug]Evaluating condition for step: 'Copy manifests' 2024-01-08T18:21:41.2473476Z ##[debug]Evaluating: and(succeeded(), ne('$(Pipeline.Workspace)/drop/ServiceBus', '')) 2024-01-08T18:21:41.2473944Z ##[debug]Evaluating and: 2024-01-08T18:21:41.2474357Z ##[debug]..Evaluating succeeded: 2024-01-08T18:21:41.2475117Z ##[debug]..=> True 2024-01-08T18:21:41.2475545Z ##[debug]..Evaluating ne: 2024-01-08T18:21:41.2475992Z ##[debug]....Evaluating String: 2024-01-08T18:21:41.2476731Z ##[debug]....=> '$(Pipeline.Workspace)/drop/ServiceBus' 2024-01-08T18:21:41.2477147Z ##[debug]....Evaluating String: 2024-01-08T18:21:41.2477473Z ##[debug]....=> '' 2024-01-08T18:21:41.2477817Z ##[debug]..=> True 2024-01-08T18:21:41.2478149Z ##[debug]=> True 2024-01-08T18:21:41.2479218Z ##[debug]Expanded: and(True, ne('$(Pipeline.Workspace)/drop/ServiceBus', '')) 2024-01-08T18:21:41.2479762Z ##[debug]Result: True 2024-01-08T18:21:41.2480245Z ##[section]Starting: Copy manifests 2024-01-08T18:21:41.2756919Z ============================================================================== 2024-01-08T18:21:41.2757203Z Task : Azure file copy 2024-01-08T18:21:41.2757320Z Description : Copy files to Azure Blob Storage or virtual machines 2024-01-08T18:21:41.2757493Z Version : 5.231.2 2024-01-08T18:21:41.2757605Z Author : Microsoft Corporation 2024-01-08T18:21:41.2757741Z Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/azure-file-copy 2024-01-08T18:21:41.2757940Z ============================================================================== 2024-01-08T18:21:44.8572912Z ##[debug]VstsTaskSdk 0.10.0 commit 787a46ec0a2df5b4d12c2e801bd3f319975c054c 2024-01-08T18:21:45.1230508Z ##[debug]Entering C:\azp\agent\_work\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\5.231.2\AzureFileCopy.ps1. 2024-01-08T18:21:45.1508158Z ##[debug]INPUT_SOURCEPATH: 'C:\azp\agent\_work\1\drop\ServiceBus\*.manifest' 2024-01-08T18:21:45.1526310Z ##[debug]INPUT_DESTINATION: 'AzureBlob' 2024-01-08T18:21:45.1587302Z ##[debug]INPUT_CONNECTEDSERVICENAMEARM: '07dbf7ab-7712-41fe-8e30-81d34a3716a0' 2024-01-08T18:21:45.1588516Z ##[debug]INPUT_STORAGEACCOUNTRM: 'svdevwesteur' 2024-01-08T18:21:45.1612904Z ##[debug]INPUT_CONTAINERNAME: 'manifests' 2024-01-08T18:21:45.1618270Z ##[debug]INPUT_BLOBPREFIX (empty) 2024-01-08T18:21:45.1697813Z ##[debug]INPUT_ENVIRONMENTNAMERM (empty) 2024-01-08T18:21:45.1698557Z ##[debug]INPUT_RESOURCEFILTERINGMETHOD: 'machineNames' 2024-01-08T18:21:45.1699825Z ##[debug]INPUT_MACHINENAMES (empty) 2024-01-08T18:21:45.1717799Z ##[debug]INPUT_VMSADMINUSERNAME (empty) 2024-01-08T18:21:45.1734739Z ##[debug]INPUT_VMSADMINPASSWORD (empty) 2024-01-08T18:21:45.1751457Z ##[debug]INPUT_TARGETPATH (empty) 2024-01-08T18:21:45.1769725Z ##[debug]INPUT_ADDITIONALARGUMENTSFORBLOBCOPY: '--overwrite true' 2024-01-08T18:21:45.1786362Z ##[debug]INPUT_ADDITIONALARGUMENTSFORVMCOPY (empty) 2024-01-08T18:21:45.1803473Z ##[debug]INPUT_CLEANTARGETBEFORECOPY: 'false' 2024-01-08T18:21:45.1834553Z ##[debug] Converted to bool: False 2024-01-08T18:21:45.1851823Z ##[debug]INPUT_COPYFILESINPARALLEL: 'true' 2024-01-08T18:21:45.1865253Z ##[debug] Converted to bool: True 2024-01-08T18:21:45.1881977Z ##[debug]INPUT_SKIPCACHECK: 'true' 2024-01-08T18:21:45.1895560Z ##[debug] Converted to bool: True 2024-01-08T18:21:45.1912447Z ##[debug]INPUT_ENABLECOPYPREREQUISITES: 'false' 2024-01-08T18:21:45.1926887Z ##[debug] Converted to bool: False 2024-01-08T18:21:45.1943660Z ##[debug]INPUT_SASTOKENTIMEOUTINMINUTES: '240' 2024-01-08T18:21:45.2054990Z ##[debug]Loading module from path 'C:\azp\agent\_work\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\5.231.2\ps_modules\RemoteDeployer\RemoteDeployer.psm1'. 2024-01-08T18:21:45.2383969Z ##[debug]Loading resource strings from: C:\azp\agent\_work\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\5.231.2\ps_modules\RemoteDeployer\module.json 2024-01-08T18:21:45.2566098Z ##[debug]Loaded 10 strings. 2024-01-08T18:21:45.2597723Z ##[debug]SYSTEM_CULTURE: 'en-US' 2024-01-08T18:21:45.2615387Z ##[debug]Loading resource strings from: C:\azp\agent\_work\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\5.231.2\ps_modules\RemoteDeployer\Strings\resources.resjson\en-US\resources.resjson 2024-01-08T18:21:45.2779158Z ##[debug]Loaded 10 strings. 2024-01-08T18:21:45.2793299Z ##[debug]Exporting function 'Invoke-RemoteScript'. 2024-01-08T18:21:45.4359662Z ##[debug]Agent running environment resource - Disk:C:\ available:16728.00MB out of 20350.00MB, Memory: used 23MB out of 8190MB, CPU: usage 3.27 2024-01-08T18:21:45.4390222Z ##[debug]Importing function 'Invoke-RemoteScript'. 2024-01-08T18:21:45.4415835Z ##[debug]Loading module from path 'C:\azp\agent\_work\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\5.231.2\ps_modules\VstsAzureHelpers_\VstsAzureHelpers_.psm1'. 2024-01-08T18:21:45.4548396Z ##[debug]$OVERRIDING $global:DebugPreference from 'Continue' to 'SilentlyContinue'. 2024-01-08T18:21:45.4564278Z ##[debug]Loading resource strings from: C:\azp\agent\_work\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\5.231.2\ps_modules\VstsAzureHelpers_/module.json 2024-01-08T18:21:45.4797046Z ##[debug]Loaded 15 strings. 2024-01-08T18:21:45.4814987Z ##[debug]SYSTEM_CULTURE: 'en-US' 2024-01-08T18:21:45.4831124Z ##[debug]Loading resource strings from: C:\azp\agent\_work\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\5.231.2\ps_modules\VstsAzureHelpers_\Strings\resources.resjson\en-US\resources.resjson 2024-01-08T18:21:45.5058876Z ##[debug]Loaded 15 strings. 2024-01-08T18:21:45.5122668Z ##[debug]Entering Get-VstsWebProxy. 2024-01-08T18:21:45.5213903Z ##[debug]AGENT_VERSION: '3.232.1' 2024-01-08T18:21:45.5275046Z ##[debug]AGENT_PROXYURL (empty) 2024-01-08T18:21:45.5310306Z ##[debug]AGENT_PROXYUSERNAME (empty) 2024-01-08T18:21:45.5345186Z ##[debug]AGENT_PROXYPASSWORD (empty) 2024-01-08T18:21:45.5380969Z ##[debug]AGENT_PROXYBYPASSLIST (empty) 2024-01-08T18:21:45.5426988Z ##[debug]Leaving Get-VstsWebProxy. 2024-01-08T18:21:45.5484448Z ##[debug]Loading module from path 'C:\azp\agent\_work\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\5.231.2\ps_modules\TlsHelper_\TlsHelper_.psm1'. 2024-01-08T18:21:45.5561046Z ##[debug]Loading resource strings from: C:\azp\agent\_work\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\5.231.2\ps_modules\TlsHelper_/module.json 2024-01-08T18:21:45.5624250Z ##[debug]Loaded 3 strings. 2024-01-08T18:21:45.5642060Z ##[debug]SYSTEM_CULTURE: 'en-US' 2024-01-08T18:21:45.5657484Z ##[debug]Loading resource strings from: C:\azp\agent\_work\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\5.231.2\ps_modules\TlsHelper_\Strings\resources.resjson\en-US\resources.resjson 2024-01-08T18:21:45.5720962Z ##[debug]Loaded 3 strings. 2024-01-08T18:21:45.5733356Z ##[debug]Exporting function 'Add-Tls12InSession'. 2024-01-08T18:21:45.5745983Z ##[debug]Exporting function 'Assert-TlsError'. 2024-01-08T18:21:45.5759438Z ##[debug]Importing function 'Add-Tls12InSession'. 2024-01-08T18:21:45.5771267Z ##[debug]Importing function 'Assert-TlsError'. 2024-01-08T18:21:45.8537841Z ##[debug]TLS 1.2 already present in session. 2024-01-08T18:21:45.9026333Z ##[debug]Exporting function 'Initialize-Azure'. 2024-01-08T18:21:45.9039977Z ##[debug]Exporting function 'CmdletHasMember'. 2024-01-08T18:21:45.9053467Z ##[debug]Exporting function 'Remove-EndpointSecrets'. 2024-01-08T18:21:45.9066972Z ##[debug]Exporting function 'Initialize-AzureRMModule'. 2024-01-08T18:21:45.9079873Z ##[debug]Exporting function 'Initialize-AzModule'. 2024-01-08T18:21:45.9092691Z ##[debug]Exporting function 'Disconnect-AzureAndClearContext'. 2024-01-08T18:21:45.9105992Z ##[debug]Exporting function 'Update-PSModulePathForHostedAgentWithLatestModule'. 2024-01-08T18:21:45.9120769Z ##[debug]Importing function 'CmdletHasMember'. 2024-01-08T18:21:45.9133243Z ##[debug]Importing function 'Disconnect-AzureAndClearContext'. 2024-01-08T18:21:45.9145761Z ##[debug]Importing function 'Initialize-AzModule'. 2024-01-08T18:21:45.9158666Z ##[debug]Importing function 'Initialize-Azure'. 2024-01-08T18:21:45.9171590Z ##[debug]Importing function 'Initialize-AzureRMModule'. 2024-01-08T18:21:45.9184152Z ##[debug]Importing function 'Remove-EndpointSecrets'. 2024-01-08T18:21:45.9311184Z ##[debug]Importing function 'Update-PSModulePathForHostedAgentWithLatestModule'. 2024-01-08T18:21:45.9332116Z ##[debug]ENDPOINT_URL_07dbf7ab-7712-41fe-8e30-81d34a3716a0: 'https://management.azure.com/' 2024-01-08T18:21:45.9348940Z ##[debug]ENDPOINT_AUTH_07dbf7ab-7712-41fe-8e30-81d34a3716a0: '********' 2024-01-08T18:21:45.9368513Z ##[debug]ENDPOINT_DATA_07dbf7ab-7712-41fe-8e30-81d34a3716a0: '{"subscriptionId":"a4d991a4-4c5d-4f90-9460-fee6348e895f","subscriptionName":"Solarvista Azure Development","environment":"AzureCloud","scopeLevel":"Subscription","creationMode":"Automatic","azureSpnRoleAssignmentId":"cbcf15b4-942a-4bbb-a84a-e92122d3068a","azureSpnPermissions":"[{\"roleAssignmentId\":\"cbcf15b4-942a-4bbb-a84a-e92122d3068a\",\"resourceProvider\":\"Microsoft.RoleAssignment\",\"provisioned\":true}]","spnObjectId":"2589e173-61fe-4a14-a4b1-621d880d2df5","appObjectId":"e7ddef10-7a1a-4055-965b-e511e31d66ad","environmentUrl":"https://management.azure.com/","galleryUrl":"https://gallery.azure.com/","serviceManagementUrl":"https://management.core.windows.net/","resourceManagerUrl":"https://management.azure.com/","activeDirectoryAuthority":"https://login.microsoftonline.com/","environmentAuthorityUrl":"https://login.windows.net/","graphUrl":"https://graph.windows.net/","microsoftGraphUrl":"https://graph.microsoft.com/","managementPortalUrl":"https://manage.windowsazure.com/","armManagementPortalUrl":"https://portal.azure.com/","activeDirectoryServiceEndpointResourceId":"https://management.core.windows.net/","sqlDatabaseDnsSuffix":".database.windows.net","AzureKeyVaultDnsSuffix":"vault.azure.net","AzureKeyVaultServiceEndpointResourceId":"https://vault.azure.net","StorageEndpointSuffix":"core.windows.net","EnableAdfsAuthentication":"false"}' 2024-01-08T18:21:45.9863492Z ##[debug]Caught exception from task script. 2024-01-08T18:21:45.9884472Z ##[debug]Error record: 2024-01-08T18:21:46.0621783Z ##[debug]C:\azp\agent\_work\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\5.231.2\AzureFileCopy.ps1 : You cannot call a method on a null-valued expression. 2024-01-08T18:21:46.0631676Z ##[debug]At line:1 char:1 2024-01-08T18:21:46.0641390Z ##[debug]+ . 'C:\azp\agent\_work\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b ... 2024-01-08T18:21:46.0651017Z ##[debug]+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2024-01-08T18:21:46.0660457Z ##[debug] + CategoryInfo : InvalidOperation: (:) [AzureFileCopy.ps1], RuntimeException 2024-01-08T18:21:46.0670342Z ##[debug] + FullyQualifiedErrorId : InvokeMethodOnNull,AzureFileCopy.ps1 2024-01-08T18:21:46.0681065Z ##[debug] 2024-01-08T18:21:46.0695510Z ##[debug]Script stack trace: 2024-01-08T18:21:46.0721059Z ##[debug]at CleanUp-PSModulePathForHostedAgent, C:\azp\agent\_work\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\5.231.2\Utility.ps1: line 1368 2024-01-08T18:21:46.0731399Z ##[debug]at , C:\azp\agent\_work\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\5.231.2\AzureFileCopy.ps1: line 69 2024-01-08T18:21:46.0742096Z ##[debug]at , : line 1 2024-01-08T18:21:46.0752469Z ##[debug]at , : line 22 2024-01-08T18:21:46.0762560Z ##[debug]at , : line 18 2024-01-08T18:21:46.0772774Z ##[debug]at , : line 1 2024-01-08T18:21:46.0958294Z ##[debug]Exception: 2024-01-08T18:21:46.1017585Z ##[debug]System.Management.Automation.RuntimeException: You cannot call a method on a null-valued expression. 2024-01-08T18:21:46.1028142Z ##[debug] at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception) 2024-01-08T18:21:46.1038349Z ##[debug] at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame) 2024-01-08T18:21:46.1048828Z ##[debug] at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) 2024-01-08T18:21:46.1059491Z ##[debug] at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) 2024-01-08T18:21:46.1069671Z ##[debug] at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame) 2024-01-08T18:21:46.1080083Z ##[debug] at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0) 2024-01-08T18:21:46.1090819Z ##[debug] at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess) 2024-01-08T18:21:46.1101039Z ##[debug] at System.Management.Automation.PSScriptCmdlet.DoEndProcessing() 2024-01-08T18:21:46.1110943Z ##[debug] at System.Management.Automation.CommandProcessorBase.Complete() 2024-01-08T18:21:46.1325786Z ##[error]You cannot call a method on a null-valued expression. 2024-01-08T18:21:46.1333601Z ##[debug]Processed: ##vso[task.logissue type=error]You cannot call a method on a null-valued expression. 2024-01-08T18:21:46.1335432Z ##[debug]Processed: ##vso[task.complete result=Failed] 2024-01-08T18:21:46.1961405Z ##[section]Finishing: Copy manifests
Repro steps
steps:
- task: PowerShell@2
displayName: List env vars and create stub file
inputs:
targetType: 'inline'
script: |
ls env:* | sort name | ft -AutoSize
Write-Host "set test data to - $($env:PIPELINE_WORKSPACE)/drop/test.manifest"
New-Item -ItemType Directory -Path "$($env:PIPELINE_WORKSPACE)/test/" -ErrorAction SilentlyContinue
'{"test":2}' > "$($env:PIPELINE_WORKSPACE)/test/test.manifest"
- task: AzureFileCopy@5
displayName: test copy
inputs:
SourcePath: $$(Pipeline.Workspace)/test/*.manifest
azureSubscription: ${{ parameters.azureSubscription }}
Destination: AzureBlob
storage: teststorageaccount
ContainerName: buildtest
AdditionalArgumentsForBlobCopy: --overwrite true