'Azure Devops Release Pipeline - git cloning fails due to long file name

I am trying to build a simple release pipeline in Azure Devops that uses an Azure git repo as an artifact and Windows VM (ADO hosted agent). In our Azure repo, some file names are long around 240-244 characters but when they are downloaded into the ADO's agent directories they are reaching the 260 character limit. When I try to deploy using this release pipeline, ADO attempts to clone the git repo but fails each time with the error "Filename too long" shown below. I understand that the filename limit in git on a Windows machine is 260 characters and that the problem can normally be fixed by running git config --global core.longpaths true but the ADO release pipeline does not allow running a custom script before it automatically performs a checkout/clone, so I am not able to run git config either.

Errors in the log:

error: unable to create file unpacked-files/return-to-the-testplace/basic-form/_abc---test-appointment-regis-thedependent-for-existing-(student-codesrequired)/_abc---Test-Appointment-Register-Dependent-for-existing-(Student-Code-Required).javascript.custom_javascript.js: Filename too long

An error occurred during download: System.InvalidOperationException: Git checkout failed with exit code: 1
   at Microsoft.VisualStudio.Services.Agent.Worker.Build.GitSourceProvider.GetSourceAsync(IExecutionContext executionContext, ServiceEndpoint endpoint, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.Services.Agent.Worker.Release.Artifacts.TfsGitArtifact.DownloadAsync(IExecutionContext executionContext, ArtifactDefinition artifactDefinition, String downloadFolderPath)
   at Microsoft.VisualStudio.Services.Agent.Worker.Release.ReleaseJobExtension.<>c__DisplayClass39_2.<<DownloadArtifacts>b__2>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.VisualStudio.Services.Agent.Worker.Release.RetryExecutor.ExecuteAsync(Func`1 action)

Looking for ideas.



Solution 1:[1]

Azure Devops Release Pipeline - git cloning fails due to long file name

If you are using the Classic mode release pipeline, you could uncheck Select all artifacts in Artifact download section of agent phase:

enter image description here

If you are using YAML pipeline, you could - download: none to skip download the artifact.

You could check the document Download for some more details:

steps:
- download: [ current | pipeline resource identifier | none ] # disable automatic download if "none"
  artifact: string ## artifact name, optional; downloads all the available artifacts if not specified
  patterns: string # patterns representing files to include; optional
  displayName: string  # friendly name to display in the UI

Solution 2:[2]

Just an update that on a Windows VM in an ADO pipeline, I am not sure if there exists a way to update the limit that the file system sets on the length of absolute paths of a file (including file name). In other words, the length of a file's directory + name (absolute path) cannot be greater than 260. In our pipeline, we had to update the directory/file name in such a way that it brought the length of the absolute path to be within the limit, and that fixed the issue with git clone.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Leo Liu-MSFT
Solution 2 Adhish Gupta