I am attempting to use a custom workflow activity to auto-increment build numbers based on the previously-successful build. This method worked with the MSBuild-based "workflow" but I cannot seem to get TFS to report the correct "last good build" for the currently-running build definition.
What I'm doing is pretty simple:
IBuildDetail build = context.GetExtension<IBuildDetail>();
IBuildDetail last = build.BuildServer.GetBuild(build.BuildDefinition.LastGoodBuildUri);
I have run a successful build already, which my code activity forced to have a build number of BuildName_1.0.0.0. But when I try to get this build and extract the version number, GetBuild complains that LastGoodBuildUri is null.
The custom build template I'm using sets both CompilationStatus and TestStatus to BuildPhaseStatus.Succeeded at the end, so TFS should be able to tell that this is a good build. What else am I missing?
Since you're running this code inside a custom activity, you need to make sure:
IBuildDetail) is completed and saved to the server prior to the schedule of this custom activity.IBuildDetail instance or the IBuildDefinition instance (build.BuildDefinition) is refreshed, to get the latest changes from the server.You can check if your build is completed by using IBuildDetail.IsFinished. If it is finished, refresh the BuildDefinition object using IBuildDefinition.Refresh().
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With