Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File conflicts when building projects in parallel on Jenkins #164

Closed
dsplaisted opened this issue Jan 19, 2018 · 5 comments
Closed

File conflicts when building projects in parallel on Jenkins #164

dsplaisted opened this issue Jan 19, 2018 · 5 comments

Comments

@dsplaisted
Copy link
Member

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]

@AArnott
Copy link
Collaborator

AArnott commented Jan 19, 2018

I solved this type of problem elsewhere in aeba285

Would anyone care to apply this same retry method to this code?

@dsplaisted
Copy link
Member Author

Would anyone care to apply this same retry method to this code?

Yes, I can do this.

@AArnott
Copy link
Collaborator

AArnott commented Jan 19, 2018

Great. I expect you'll need to move my utility method to the main assembly.

@dsplaisted
Copy link
Member Author

How do you feel about moving it to a shared folder and compiling it into each assembly? That's the way I went, probably because I've been working in the MSBuild code base which does that a lot :-)

@AArnott
Copy link
Collaborator

AArnott commented Jan 19, 2018

I'm not a huge fan of shared files, but it's better than making the class public, so I think it's the right choice here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants