문제

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:

  1. The build (IBuildDetail) is completed and saved to the server prior to the schedule of this custom activity.
  2. The 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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top