Skip to content

File conflicts when building projects in parallel on Jenkins #164

@dsplaisted

Description

@dsplaisted

I'm getting errors in CI where the SetCloudBuildVariables task is failing to write the jenkins_build_number.txt, presumably because other projects are writing it at the same time. Should Jenkins.WriteVersionFile be updated to use the same retry logic that was added in aeba285?

C:\Users\dotnet-bot.nuget\packages\nerdbank.gitversioning\2.1.7\build\Nerdbank.GitVersioning.targets(117,5): error MSB4018: The "Nerdbank.GitVersioning.Tasks.SetCloudBuildVariables" task failed unexpectedly.
System.IO.IOException: The process cannot access the file 'D:\j\w\innerloop_Win---268ca7be\jenkins_build_number.txt' because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
at System.IO.File.InternalWriteAllText(String path, String contents, Encoding encoding, Boolean checkHost)
at System.IO.File.WriteAllText(String path, String contents, Encoding encoding)
at Nerdbank.GitVersioning.CloudBuildServices.Jenkins.WriteVersionFile(String buildNumber)
at Nerdbank.GitVersioning.CloudBuildServices.Jenkins.SetCloudBuildNumber(String buildNumber, TextWriter stdout, TextWriter stderr)
at Nerdbank.GitVersioning.Tasks.SetCloudBuildVariables.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() [D:\j\w\innerloop_Win---268ca7be\src\Utilities.UnitTests\Microsoft.Build.Utilities.UnitTests.csproj]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions