我正在使用现有的TFS构建和发布管理设置,并且对它所使用的(现已弃用的)XAML构建系统知之甚少。
在下面的构建模板的代码片段中,构建了我的项目,运行了测试,然后启动了一个序列,将已编译的项目交给TFS Release Management进行部署。
<Sequence DisplayName="Overall build process">
<mtbac:SetBuildNumber DisplayName="Update build number" BuildNumberFormat="[BuildNumberFormat]" />
<mtbwa:AgentScope DisplayName="Run on agent" MaxExecutionTime="[AgentSettings.GetValue(Of TimeSpan)("MaxExecutionTime", new System.TimeSpan(0,0,0))]" MaxWaitTime="[AgentSettings.GetValue(Of TimeSpan)("MaxWaitTime", new System.TimeSpan(4,0,0))]" ReservationSpec="[AgentSettings.CreateAgentReservationSpec()]">
<mtbac:InitializeEnvironment DisplayName="Initialize environment" />
<mtbat:TfGetSources DisplayName="Get sources from Team Foundation Version Control" CleanWorkspace="[CleanWorkspace]" CreateLabel="[CreateLabel]" VersionOverride="[GetVersion]" />
<mtba:AssociateChanges DisplayName="Associate the changesets that occurred since the last good build" UpdateWorkItems="[UpdateAssociatedWorkItems]" />
<TryCatch DisplayName="Try" mtbwt:BuildTrackingParticipant.Importance="Low">
<TryCatch.Try>
<Sequence DisplayName="Compile, Test and Publish">
<mtba:RunScript DisplayName="Run optional script before MSBuild" FilePath="[AdvancedBuildSettings.GetValue(Of String)("PreActionScriptPath", String.Empty)]" Arguments="[AdvancedBuildSettings.GetValue(Of String)("PreActionScriptArguments", String.Empty)]" />
<mtba:RunMSBuild DisplayName="Run MSBuild" OutputLocation="[OutputLocation]" CleanBuild="[CleanBuild]" CommandLineArguments="[String.Format("/p:SkipInvalidConfigurations=true {0}", AdvancedBuildSettings.GetValue(Of String)("MSBuildArguments", String.Empty))]" ConfigurationsToBuild="[ConfigurationsToBuild]" ProjectsToBuild="[ProjectsToBuild]" ToolPlatform="[AdvancedBuildSettings.GetValue(Of String)("MSBuildPlatform", "Auto")]" RunCodeAnalysis="[AdvancedBuildSettings.GetValue(Of String)("RunCodeAnalysis", "AsConfigured")]" />
<mtba:RunScript DisplayName="Run optional script after MSBuild" FilePath="[AdvancedBuildSettings.GetValue(Of String)("PostActionScriptPath", String.Empty)]" Arguments="[AdvancedBuildSettings.GetValue(Of String)("PostActionScriptArguments", String.Empty)]" />
<mtba:RunScript DisplayName="Run optional script before Test Runner" FilePath="[AdvancedTestSettings.GetValue(Of String)("PreActionScriptPath", String.Empty)]" Arguments="[AdvancedTestSettings.GetValue(Of String)("PreActionScriptArguments", String.Empty)]" />
<mtba:RunAgileTestRunner DisplayName="Run VS Test Runner" Enabled="[Not AdvancedTestSettings.GetValue(Of Boolean)("DisableTests", false)]" TestSpecs="[AutomatedTests]" ConfigurationsToTest="[ConfigurationsToBuild]" />
<mtba:RunScript DisplayName="Run optional script after Test Runner" FilePath="[AdvancedTestSettings.GetValue(Of String)("PostActionScriptPath", String.Empty)]" Arguments="[AdvancedTestSettings.GetValue(Of String)("PostActionScriptArguments", String.Empty)]" />
<mtba:RunTestImpact DisplayName="Get Impacted Tests" Enabled="[AdvancedTestSettings.GetValue(Of Boolean)("AnalyzeTestImpact", true)]" />
<Sequence DisplayName="Process the release">
<Sequence.Variables>
<Variable x:TypeArguments="x:String" Name="buildDirectory" />
</Sequence.Variables>
<mtbwa:GetBuildDirectory DisplayName="Get the Build Directory" Result="[buildDirectory]" />
<If Condition="[ProcessReleaseTokens]" DisplayName="If ProcessReleaseTokens is set">
<If.Then>
<Sequence DisplayName="Initialize tokens">
目前,如果测试失败,序列步骤仍会执行,并且部署了损坏的构建。我启用了“失败构建测试失败”选项。
我需要在出现测试失败时阻止部署,无论是通过停止运行发布步骤还是修改发布管理中的进程(我都倾向于在发生构建失败时根本不接触发布管理)。
答案 0 :(得分:0)
您可以让您的构建只是吐出WebDeploy包(例如DeployTarget = Package),然后在运行PowerShell脚本的工作流结束时有一个 InvokeProcess 来进行实际部署。 / p>
答案 1 :(得分:0)
您可以更新XAML定义模板以实现此目的。有关详细信息,请参阅此问题中的答案:Release management releasing failed builds also - Triggering release from failed builds
如果链接不起作用,请在此处引用:
- 在“If Not DisableTests”下面移动了“如果设置了ReleaseBuild”活动。
- 将“如果设置了ReleaseBuild”的条件更改为:ReleaseBuild和(treatTestFailureAsBuildFailure = False或 (treatTestFailureAsBuildFailure和(BuildDetail.TestStatus&lt;&gt; Microsoft.TeamFoundation.Build.Client.BuildPhaseStatus.Failed)))和 BuildDetail.CompilationStatus&lt;&gt; Microsoft.TeamFoundation.Build.Client.BuildPhaseStatus.Failed
- 内部“如果ReleaseBuild已设置”活动的其他部分,将WriteBuildMessage的消息更改为:“跳过执行,因为要么 未设置ReleaseBuild或某些测试失败或编译有 失败“
- 最后签入模板,就是这样,失败的构建将不会被部署。
醇>