ArchiveFiles@2 task. Failed with following error: zip warning: could not open for reading: .git/gc.pid
Asked Answered
O

1

1

I’ve a failed job with the following errors when merging a pull request with DEV branch.

zip warning: could not open for reading: .git/gc.pid
zip warning: could not open for reading: .git/gc.log.lock

The build is successful when I push the repo to the azure devops.

This is the task for my pipeline:

- task: ArchiveFiles@2
  displayName: 'Archive Files'
  inputs:
    rootFolderOrFile: '$(buildRootDirectory)'
    includeRootFolder: false
    archiveType: 'zip'
    archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
    replaceExistingArchive: true

Don't see any of those files .git/gc.pid and .git/gc.log.lock in my codebase.

Overshoe answered 28/3, 2023 at 6:25 Comment(0)
Q
1

Check if this is because of the Git garbage collection, by disabling temporarily gc, before the ArchiveFiles step:

- task: CmdLine@2
  displayName: 'Set gc.auto to 0'
  inputs:
    script: |
      git config --global gc.auto 0

... ArchiveFiles@2

- task: CmdLine@2
  displayName: 'Set gc.auto to default: restore gc'
  inputs:
    script: |
      git config --global --unset gc.auto

You might also want to clean out any gc file before the Archive step:

- task: PowerShell@2
  displayName: 'Cleanup gc files'
  inputs:
    targetType: 'inline'
    script: |
      $gcFiles = Get-ChildItem -Path "$(System.DefaultWorkingDirectory)" -Include .git\gc* -Recurse -Force
      if ($gcFiles) {
        Remove-Item -Path $gcFiles -Force -Recurse
      }
Quade answered 28/3, 2023 at 6:53 Comment(5)
Thanks for the tips. I'm running ubuntu vm. I added the a script to copy the files and I got the following message ##[error]Error: Entry "/home/vsts/work/1/s/.git/gc.log.lock" does not existOvershoe
@Overshoe At which point do you get that error message? And did you clean up any gc file before the Archive step?Quade
I added the steps you mentioned. 1.- 'Set gc.auto to 0' 2.- CopyFiles and exclude .git folder (which probably not a good idea since this is the pipeline for the Build package) 3.- Archive Files. 4.- Set gc.auto to default: restore gc. The error I mentioned before is on the step 3 Archive Files.Overshoe
@Overshoe Before step 3, could you insert the "clean up gc file" step?Quade
it works I added a equivalent "clean up gc file" for bash find .git -type f -name "gc*" -delete and it does the magic. Thanks for the help!Overshoe

© 2022 - 2024 — McMap. All rights reserved.