microsoft / navcontainerhelper

Official Microsoft repository for BcContainerHelper, a PowerShell module, which makes it easier to work with Business Central Containers on Docker.
MIT License
385 stars 247 forks source link

Exception calling "Move" with arguments "2": "Access denied to the path #1920

Closed deadmouse closed 3 years ago

deadmouse commented 3 years ago

Describe the issue In the "Run Pipeline" job, I get this error: Exception calling "Move" with arguments "2": "Access denied to the path...

Scripts used to create container and cause the issue

trigger:
- master

pool:
  name: 'cba'

variables:
- group: BuildVariables

jobs:
- job: Build
  timeoutInMinutes: 300
  variables:
    build.clean: all
    platform: x64
    version: 'ci'
    appVersion: '2.0'
    appBuild: $(Build.BuildID)
    appRevision: 0
    skipComponentGovernanceDetection: True

  steps:
  - task: PowerShell@2
    displayName: 'Set BuildNumber'
    inputs:
      targetType: inline
      script: 'Write-Host "##vso[build.updatebuildnumber]$(appVersion).$(appBuild).$(appRevision)"'

  - task: PowerShell@2
    displayName: 'Run Pipeline'
    env:
      InsiderSasToken: '$(InsiderSasToken)'
      LicenseFile: '$(LicenseFile)'
      CodeSignCertPfxFile: '$(CodeSignCertPfxFile)'
      CodeSignCertPfxPassword: '$(CodeSignCertPfxPassword)'
    inputs:
      targetType: filePath
      filePath: 'scripts\DevOps-Pipeline.ps1'
      arguments: '-environment "AzureDevOps" -version "$(version)" -appBuild $(appBuild) -appRevision $(appRevision)'
      failOnStderr: true

  - task: PublishBuildArtifacts@1
    displayName: 'Publish Artifacts'
    inputs:
      PathtoPublish: '$(Build.ArtifactStagingDirectory)'
      ArtifactName: output

  - task: PowerShell@2
    displayName: 'Cleanup'
    condition: always()
    inputs:
      targetType: filePath
      filePath: 'scripts\Cleanup.ps1'
      arguments: '-environment "AzureDevOps"'
      failOnStderr: false

Full output of scripts

Version      : 2.180.1
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
==============================================================================
Generating script.
Formatted command: . 'C:\agent\_work\1\s\scripts\DevOps-Pipeline.ps1' -environment "AzureDevOps" -version "ci" -appBuild 81 -appRevision 0
========================== Starting Command Output ===========================
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'C:\agent\_work\_temp\385aeb87-9eba-4479-aeef-5c77f20df9f9.ps1'"
Set artifact = ///es/Current
Set pipelineName = abc-ci
Set containerName = bc2019-abc-ci
Set installApps = ''
Set installTestApps = ''
Set previousApps = ''
Set appSourceCopMandatoryAffixes = ''
Set appSourceCopSupportedCountries = ''
Set appFolders = 'app,base'
Set testFolders = 'test'
Set memoryLimit = '6G'
Set additionalCountries = 'es'
Set genericImageName = ''
Set vaultNameForLocal = 'BuildVariables'
Set bcContainerHelperVersion = 'Latest'
Set installTestRunner = False
Set installTestFramework = False
Set installTestLibraries = False
Set installPerformanceToolkit = False
Set enableCodeCop = False
Set enableAppSourceCop = False
Set enablePerTenantExtensionCop = True
Set enableUICop = False
Set doNotSignApps = True
Set doNotRunTests = False
Set cacheImage = True
Set CreateRuntimePackages = False
Downloading https://bccontainerhelper.azureedge.net/public/2.0.11.zip
##[error]C:\agent\_work\1\s\scripts\DevOps-Pipeline.ps1 : Exception calling "Move" with arguments "2": "Access denied
to the path
'C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp\54a5c8ff-0967-4261-99b6-911e87a31661\BcContainerHelper'."
In C:\agent\_work\_temp\385aeb87-9eba-4479-aeef-5c77f20df9f9.ps1: 3 Character: 1
+ . 'C:\agent\_work\1\s\scripts\DevOps-Pipeline.ps1' -environment "Azur ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [DevOps-Pipeline.ps1], MethodInvocationException
    + FullyQualifiedErrorId : IOException,DevOps-Pipeline.ps1
##[error]PowerShell exited with code '1'.
Finishing: Run Pipeline

Additional context In my Windows Server, the Network Service account is the one used for the Azure Pipelines Agent service and I have already given to this user permissions to several folders in C:\Windows\ServiceProfiles... but it keeps throwing that error. On the other hand, my "BuildVariables" in Azure DevOps > Library is empty, since I don't have Azure Key Vault. Is this mandatory or "skippable"? (image attached) Could this be source of the error?

Screenshots image

deadmouse commented 3 years ago

Problem is solved. I reinstalled the agent and recreated the build pipeline.