当另一个在 TFS 2008 中成功完成时触发构建

发布于 2024-09-25 02:10:25 字数 165 浏览 0 评论 0原文

这是我习惯于 TeamCity 的一项功能 - 我可以指定某个构建配置将由另一个构建配置的成功触发。

我什至可以将一个构建的结果传递给另一个构建 - 但也许这要求太多了。

我正在 TFS2008 中寻找类似的功能,是否有一种方法可以在构建配置上设置触发器,使其在另一个成功完成后启动?

This is a feature I'm used to from TeamCity - I could specify that a certain build configuration will be triggered by the success of another build configuration.

I could even pass the results of one build to another - but perhaps this is asking too much.

I'm looking for a similar functionality in TFS2008, is there a way to set a trigger on a build configuration that it shall start after another finished successfully?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

喜爱皱眉﹌ 2024-10-02 02:10:31

我在 TFSBuild.proj 中使用以下目标:

将新目标注入构建过程。如果成功创建了“drop”,我们只会触发依赖构建:

<PropertyGroup>
    <DropBuildDependsOn>
        $(DropBuildDependsOn);
        CreateDependentBuildItemGroup;
        TriggerDependentBuilds;
    </DropBuildDependsOn>
</PropertyGroup>

创建一个项目组,其中包含我们要触发的依赖构建的列表(包含属性将列出依赖构建的名称)出现在构建资源管理器中 - 在下面的例子中,依赖构建称为“集成”)。在我们的构建过程中,我们有时想要触发多个构建,并且我们希望将下一个构建指向当前构建生成的二进制文件(在本示例中,我想针对生成的二进制文件运行集成测试)。请注意绕过配置名称中的空格的黑客行为 - 例如“任何 CPU”将导致 MsBuild 参数出现问题。使用这种格式,我们可以为每个依赖构建自定义 MSBuild 参数。

<Target Name="CreateDependentBuildItemGroup">
    <ItemGroup>
        <DependentBuild Include="Integration">
            <!--Using 8dot3 format for "Mixed Platforms" as it's tricky (impossible?) to pass a space char within /msbuildarguments of tfsbuild-->
            <MsBuildArgs>/p:CallingBuildDropFolder=$(DropLocation)\$(BuildNumber)\Mixedp~1\Ship;CiSmallBuildNumber=$(CiSmallBuildNumber);BuildNumberPostFix=$(BuildNumberPostFix)</MsBuildArgs>
            <PriorityArg>/priority:AboveNormal</PriorityArg>
        </DependentBuild>
    </ItemGroup>    
</Target>

现在,触发构建。请注意,我们使用自定义 GetOption:我们希望确保依赖构建使用当前构建使用的相同变更集 - 我们不能使用最新版本,因为有人可能同时签入 - 因此我们希望所有依赖构建都加入我们的“链”都基于相同的变更集。实际的命令在 Exec 中,BuildStep 的内容是确保我们报告 Exec 的成功(或失败)。

<Target Name="TriggerDependentBuilds"
        Condition=" '$(CompilationStatus)' == 'Succeeded' ">
    <BuildStep TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
               BuildUri="$(BuildUri)"
               Name="TriggerStep"
               Message="Triggering Dependent Builds">
        <Output TaskParameter="Id"
                PropertyName="TriggerStepId" />
    </BuildStep>

    <PropertyGroup>
        <TriggerBuildCommandBase>TfsBuild start $(TeamFoundationServerUrl) $(TeamProject)</TriggerBuildCommandBase>
    </PropertyGroup>

    <Exec
        ContinueOnError="true"
        WorkingDirectory="C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE"
        Command="$(TriggerBuildCommandBase) %(DependentBuild.Identity) /queue /getOption:Custom /customGetVersion:$(GetVersion) %(DependentBuild.PriorityArg) /msbuildarguments:"%(DependentBuild.MsBuildArgs)"">
        <Output TaskParameter="ExitCode"
                ItemName="TfsBuildResult"/>
    </Exec>

    <BuildStep Condition="'@(TfsBuildResult)'=='0'"
               TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
               BuildUri="$(BuildUri)"
               Id="$(TriggerStepId)"
               Status="Succeeded" />
    <BuildStep Condition="'@(TfsBuildResult)'!='0'"
               TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
               BuildUri="$(BuildUri)"
               Id="$(TriggerStepId)"
               Status="Failed" />
</Target>

我希望这有帮助...

I use the following target in my TFSBuild.proj:

Inject the new targets into the build process. We only trigger dependent builds if a "drop" was successfully created:

<PropertyGroup>
    <DropBuildDependsOn>
        $(DropBuildDependsOn);
        CreateDependentBuildItemGroup;
        TriggerDependentBuilds;
    </DropBuildDependsOn>
</PropertyGroup>

Create a itemgroup that contains a list of the dependent builds we want to trigger (the Include attribute will list the name of the dependent build as it appears in the build explorer - in my case below, the dependant build is called "Integration"). In our build process, we sometimes want to trigger more than one build, and we want to point the next build at the binaries that were produced by the current build (in this example, I want to run Integration tests against the binaries produced). Notice the hack to get around spaces in configuration names - eg "Any CPU" will cause a problem in the MsBuild args. Using this format, we can have custom MSBuild args per dependent build.

<Target Name="CreateDependentBuildItemGroup">
    <ItemGroup>
        <DependentBuild Include="Integration">
            <!--Using 8dot3 format for "Mixed Platforms" as it's tricky (impossible?) to pass a space char within /msbuildarguments of tfsbuild-->
            <MsBuildArgs>/p:CallingBuildDropFolder=$(DropLocation)\$(BuildNumber)\Mixedp~1\Ship;CiSmallBuildNumber=$(CiSmallBuildNumber);BuildNumberPostFix=$(BuildNumberPostFix)</MsBuildArgs>
            <PriorityArg>/priority:AboveNormal</PriorityArg>
        </DependentBuild>
    </ItemGroup>    
</Target>

Now, trigger the builds. Notice that we use a Custom GetOption: we want to make sure that dependent builds use the same changeset that the current build used - we can't use Latest, cos someone may have checked in in the meantime - so we want all dependent builds in our "chain" to all be based of the same changeset. The actual command is within the Exec, and the BuildStep stuff is to make sure we report the success (or failure) of the Exec.

<Target Name="TriggerDependentBuilds"
        Condition=" '$(CompilationStatus)' == 'Succeeded' ">
    <BuildStep TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
               BuildUri="$(BuildUri)"
               Name="TriggerStep"
               Message="Triggering Dependent Builds">
        <Output TaskParameter="Id"
                PropertyName="TriggerStepId" />
    </BuildStep>

    <PropertyGroup>
        <TriggerBuildCommandBase>TfsBuild start $(TeamFoundationServerUrl) $(TeamProject)</TriggerBuildCommandBase>
    </PropertyGroup>

    <Exec
        ContinueOnError="true"
        WorkingDirectory="C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE"
        Command="$(TriggerBuildCommandBase) %(DependentBuild.Identity) /queue /getOption:Custom /customGetVersion:$(GetVersion) %(DependentBuild.PriorityArg) /msbuildarguments:"%(DependentBuild.MsBuildArgs)"">
        <Output TaskParameter="ExitCode"
                ItemName="TfsBuildResult"/>
    </Exec>

    <BuildStep Condition="'@(TfsBuildResult)'=='0'"
               TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
               BuildUri="$(BuildUri)"
               Id="$(TriggerStepId)"
               Status="Succeeded" />
    <BuildStep Condition="'@(TfsBuildResult)'!='0'"
               TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
               BuildUri="$(BuildUri)"
               Id="$(TriggerStepId)"
               Status="Failed" />
</Target>

I hope that helps...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文