2013-09-29 49 views
2

我的工作,通過使用代碼踢過另一個構建一個TFS生成定義博客在這裏:Queue another Team Build when one Team Build succeedsTFS - 鏈接構建 - 如何將信息從一個構建傳遞到下一個構建?

我很感興趣,在文章底部的第一對夫婦的意見。基本上,我只是想將第一個版本號傳遞給下一個版本。

這是相當簡單的改變XAML模板傳遞一個IBuildRequest而不是​​...

<Sequence.Variables> 
    <Variable x:TypeArguments="mtbc:IBuildDefinition" Default="[BuildServer.GetBuildDefinition(BuildDetail.TeamProject, buildChainItem)]" Name="ChainedBuildDefinition" /> 
    <Variable x:TypeArguments="mtbc:IBuildRequest" Default="[BuildServer.CreateBuildRequest(ChainedBuildDefinition.Uri)]" Name="ChainedBuildRequest" /> 
    <Variable x:TypeArguments="mtbc:IQueuedBuild" Default="[BuildServer.QueueBuild(ChainedBuildRequest)]" Name="QueuedChainedBuild" /> 
</Sequence.Variables> 

什麼被證明更加棘手的是將當前版本號爲新IBuildRequestProcessParameters

我可以看到如何使用<Variable>像上面的Default屬性添加的代碼行,但似乎每行必須返回的東西。但是我想運行的一些行只是調用一個沒有返回值的方法,例如將新元素添加到ProcessParameters字典中時。這是我已經嘗試過...

<Sequence.Variables> 
    <Variable x:TypeArguments="mtbc:IBuildDefinition" Default="[BuildServer.GetBuildDefinition(BuildDetail.TeamProject, buildChainItem)]" Name="ChainedBuildDefinition" /> 
    <Variable x:TypeArguments="mtbc:IBuildRequest" Default="[BuildServer.CreateBuildRequest(ChainedBuildDefinition.Uri)]" Name="ChainedBuildRequest" /> 

    <Variable x:TypeArguments="x:String" Default="[ChainedBuildRequest.ProcessParameters]" Name="NextProcessParameters" /> 
    <!-- deserialize processparameters string into dictionary --> 
    <Variable x:TypeArguments="scg:IDictionary(x:String, x:Object)" Default="[WorkflowHelpers.DeserializeProcessParameters(NextProcessParameters)]" Name="DeserializedProcessParameters" /> 
    <!-- *** add new parameter, but no return value, so will not work *** --> 
    <Variable x:TypeArguments="x:String" Default="[DeserializedProcessParameters.Add(&quot;PreviousBuildNumber&quot;, &quot;1.1.1.1&quot;)]" Name="AddNewParameter" /> 
    <!-- serialize back into a string --> 
    <Variable x:TypeArguments="x:String" Default="[WorkflowHelpers.SerializeProcessParameters(DeserializedProcessParameters)]" Name="SerializedProcessParameters" /> 
    <!-- *** also no return value, so will not work *** --> 
    <Variable x:TypeArguments="x:String" Default="ChainedBuildRequest.ProcessParameters = SerializedProcessParameters" Name="UpdateProcessParameters" /> 

    <Variable x:TypeArguments="mtbc:IQueuedBuild" Default="[BuildServer.QueueBuild(ChainedBuildRequest)]" Name="QueuedChainedBuild" /> 
</Sequence.Variables> 

所以,我的第一個問題......是否有可能運行序列變量中沒有返回值的代碼行?

我對這些技術很陌生,所以可能錯過了一些根本性的東西。如果有人有不同的方法將先前的版本號傳遞給下一個版本,那麼也會非常感激。

非常感謝,如果你走到這一步:-)

+1

你可以嘗試InvokeMethod活動: http://msdn.microsoft.com/en-us/library/vstudio/system.activities .statements.invokemethod(v = vs.100).aspx –

+0

謝謝Jason。它看起來很有希望。我會盡快嘗試。在[WCF和WF Samples for .NET 4]中有一些優秀的例子(http://www.microsoft.com/en-us/download/details.aspx?id=21459) – davmos

回答

1

感謝@Jason Stangroome他原來的博客文章,指着我對InvokeMethod活動。憑藉着出色的WCF & WF Samples for .NET 4的幫助下,我更新了XAML這樣的:

<Sequence DisplayName="Queue chained build" sap:VirtualizedContainerService.HintSize="222,146"> 
    <Sequence.Variables> 
     <Variable x:TypeArguments="mtbc:IBuildDefinition" Default="[BuildServer.GetBuildDefinition(BuildDetail.TeamProject, buildChainItem)]" Name="ChainedBuildDefinition" /> 
     <Variable x:TypeArguments="mtbc:IBuildRequest" Default="[BuildServer.CreateBuildRequest(ChainedBuildDefinition.Uri)]" Name="ChainedBuildRequest" /> 
     <Variable x:TypeArguments="x:String" Default="[ChainedBuildRequest.ProcessParameters]" Name="NextBuildProcessParameters" /> 
     <Variable x:TypeArguments="scg:IDictionary(x:String, x:Object)" Default="[WorkflowHelpers.DeserializeProcessParameters(NextBuildProcessParameters)]" Name="DeserializedParameters" /> 
     <Variable x:TypeArguments="mtbc:IQueuedBuild" Name="QueuedChainedBuild" /> 
    </Sequence.Variables> 

    <sap:WorkflowViewStateService.ViewState> 
     <scg:Dictionary x:TypeArguments="x:String, x:Object"> 
      <x:Boolean x:Key="IsExpanded">True</x:Boolean> 
     </scg:Dictionary> 
    </sap:WorkflowViewStateService.ViewState> 

    <InvokeMethod DisplayName="Add current build number to ProcessParameters" sap:VirtualizedContainerService.HintSize="299.663333333333,127.553333333333" MethodName="Add"> 
     <InvokeMethod.TargetObject> 
      <InArgument x:TypeArguments="scg:IDictionary(x:String, x:Object)">[DeserializedParameters]</InArgument> 
     </InvokeMethod.TargetObject> 
     <InArgument x:TypeArguments="x:String">["ParentBuildNumber"]</InArgument> 
     <InArgument x:TypeArguments="x:Object">[BuildDetail.BuildNumber]</InArgument> 
    </InvokeMethod> 

    <InvokeMethod DisplayName="Re-serialize ProcessParameters" sap:VirtualizedContainerService.HintSize="299.663333333333,127.553333333333" MethodName="SerializeProcessParameters" TargetType="mtbw:WorkflowHelpers"> 
     <InvokeMethod.Result> 
      <OutArgument x:TypeArguments="x:String">[ChainedBuildRequest.ProcessParameters]</OutArgument> 
     </InvokeMethod.Result> 
     <InArgument x:TypeArguments="scg:IDictionary(x:String, x:Object)">[DeserializedParameters]</InArgument> 
    </InvokeMethod> 

    <InvokeMethod DisplayName="Queue Next Build" sap:VirtualizedContainerService.HintSize="299.663333333333,127.553333333333" MethodName="QueueBuild"> 
     <InvokeMethod.Result> 
      <OutArgument x:TypeArguments="mtbc:IQueuedBuild">[QueuedChainedBuild]</OutArgument> 
     </InvokeMethod.Result> 
     <InvokeMethod.TargetObject> 
      <InArgument x:TypeArguments="mtbc:IBuildServer">[BuildServer]</InArgument> 
     </InvokeMethod.TargetObject>      
     <InArgument x:TypeArguments="mtbc:IBuildRequest">[ChainedBuildRequest]</InArgument> 
    </InvokeMethod> 

    <mtbwa:WriteBuildMessage sap:VirtualizedContainerService.HintSize="200,22" Importance="[Microsoft.TeamFoundation.Build.Client.BuildMessageImportance.High]" Message="[String.Format(&quot;Queued chained build '{0}'&quot;, buildChainItem)]" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces" /> 
</Sequence> 
相關問題