Release Management sets builds to Retain Indefinit

2019-04-09 13:04发布

We are using Microsoft's Release Management tool for automating the deployment of our solution to our various dev servers. This tool is ideal for us because it can perform more complicated deployments that span multiple servers. In this sense, it is working fine and everything is deploying correctly.

A minor issue is that after Release Management automatically deploys a build, it sets the build to "Retain Indefinitely" which is indicated by the Lock icon. Since we are doing continuous deployment, we are retaining a large number of builds and the Build Definition's retention policy is overridden. I therefore have to go in periodically and highlight all of the previous builds and unselect Retain Indefinitely.

Because we are not deploying past dev with Release Management (we unfortunately aren't allowed to), we don't need to keep all of these dev builds around.

Is there a way to change Release Management so that it doesn't set builds to Retain Indefinitely?

Update: Since this is not currently possible, if you would like this feature, please vote for it on UserVoice: https://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/6537614-allow-retain-indefinitely-to-not-be-set

3条回答
祖国的老花朵
2楼-- · 2019-04-09 13:54

Release Management follows the model of Lab Management, whereby if a Build is deployed it is retained indefinately.

This allows you to alter the build quality etc as the build is verified and signed off, you may then promote / do whatever with that build without fear that it will be deleted by the retention policy.

you just need to do it as a daily / weekly / monthly admin task, choose your build from the drop down list in the build screen and then show all.

highlight all of the builds and then click the remove retention button.

if it bothers you that much you could write a script to find all of the builds and then remove the lock.

psudo:

BuildDefinition.KeepForever = False;
查看更多
Summer. ? 凉城
3楼-- · 2019-04-09 13:57

I have a solution to this, rather a workaround.

I have customized our build definition with the following Sequence (for TFS 2013) at the beginning of the workflow. This sequence grabs all succeeded builds for the definition and clears the Retain Indefinitely.

This means only the last ran build will have the flag. It also means you can't set a build as retain indefinitely for that definition. That is OK for us in this specific situation as it is for continuous integration builds (like the poster).

Edit: Changing to include All builds (was Successful only) as a build is marked as failed and still set to retain indefinitely if the build succeeds but release fails.

<Sequence DisplayName="Cleanup: Clear 'Retain Indefinitely' from previous builds">
  <Sequence.Variables>
    <Variable x:TypeArguments="mtbc:IBuildDetail" Name="localBuildDetail" />
    <Variable x:TypeArguments="mtbc:IBuildDetailSpec" Name="localBuildDetailSpec" />
    <Variable x:TypeArguments="mtbc:IBuildQueryResult" Name="localBuildQueryResult" />
  </Sequence.Variables>
  <mtbwa:GetBuildDetail DisplayName="Get the Build Details" Result="[localBuildDetail]" />
  <InvokeMethod DisplayName="Create the Build Detail Spec" MethodName="CreateBuildDetailSpec">
    <InvokeMethod.TargetObject>
      <InArgument x:TypeArguments="mtbc:IBuildServer">[localBuildDetail.BuildServer]</InArgument>
    </InvokeMethod.TargetObject>
    <InvokeMethod.Result>
      <OutArgument x:TypeArguments="mtbc:IBuildDetailSpec">[localBuildDetailSpec]</OutArgument>
    </InvokeMethod.Result>
    <InArgument x:TypeArguments="x:String">[localBuildDetail.TeamProject]</InArgument>
  </InvokeMethod>
  <Assign DisplayName="Setting Query Order Descending">
    <Assign.To>
      <OutArgument x:TypeArguments="mtbc:BuildQueryOrder">[localBuildDetailSpec.QueryOrder]</OutArgument>
    </Assign.To>
    <Assign.Value>
      <InArgument x:TypeArguments="mtbc:BuildQueryOrder">FinishTimeDescending</InArgument>
    </Assign.Value>
  </Assign>
  <Assign DisplayName="Setting Build Definition">
    <Assign.To>
      <OutArgument x:TypeArguments="x:String">[localBuildDetailSpec.DefinitionSpec.Name]</OutArgument>
    </Assign.To>
    <Assign.Value>
      <InArgument x:TypeArguments="x:String">[localBuildDetail.BuildDefinition.Name]</InArgument>
    </Assign.Value>
  </Assign>
  <Assign DisplayName="Setting Query Type to All Builds">
    <Assign.To>
      <OutArgument x:TypeArguments="mtbc:BuildStatus">[localBuildDetailSpec.Status]</OutArgument>
    </Assign.To>
    <Assign.Value>
      <InArgument x:TypeArguments="mtbc:BuildStatus">All</InArgument>
    </Assign.Value>
  </Assign>
  <InvokeMethod DisplayName="Getting Previous Builds" MethodName="QueryBuilds">
    <InvokeMethod.TargetObject>
      <InArgument x:TypeArguments="mtbc:IBuildServer">[localBuildDetail.BuildServer]</InArgument>
    </InvokeMethod.TargetObject>
    <InvokeMethod.Result>
      <OutArgument x:TypeArguments="mtbc:IBuildQueryResult">[localBuildQueryResult]</OutArgument>
    </InvokeMethod.Result>
    <InArgument x:TypeArguments="mtbc:IBuildDetailSpec">[localBuildDetailSpec]</InArgument>
  </InvokeMethod>
  <ForEach DisplayName="Loop through all builds and undo 'Retain Indefinitely' set by Release Management."
           x:TypeArguments="mtbc:IBuildDetail"
           Values="[localBuildQueryResult.Builds]">
    <ActivityAction x:TypeArguments="mtbc:IBuildDetail">
      <ActivityAction.Argument>
        <DelegateInArgument x:TypeArguments="mtbc:IBuildDetail" Name="localBuild" />
      </ActivityAction.Argument>
      <Sequence DisplayName="Checking Build Next Build">
        <If Condition="[localBuild.KeepForever = True]" DisplayName="If the build is marked 'Retain Indefinitely'">
          <If.Then>
            <Sequence DisplayName="Updating Build Details">
              <Assign DisplayName="Setting KeepForver to false">
                <Assign.To>
                  <OutArgument x:TypeArguments="x:Boolean">[localBuild.KeepForever]</OutArgument>
                </Assign.To>
                <Assign.Value>
                  <InArgument x:TypeArguments="x:Boolean">false</InArgument>
                </Assign.Value>
              </Assign>
              <InvokeMethod DisplayName="Saving Build Details" MethodName="Save">
                <InvokeMethod.TargetObject>
                  <InArgument x:TypeArguments="mtbc:IBuildDetail">[localBuild]</InArgument>
                </InvokeMethod.TargetObject>
              </InvokeMethod>
            </Sequence>
          </If.Then>
        </If>
      </Sequence>
    </ActivityAction>
  </ForEach>
</Sequence>
查看更多
爱情/是我丢掉的垃圾
4楼-- · 2019-04-09 13:58

As of RM for TFS 2013.3, this is not possible. According to Teodora Stanev on this post, this is by design.

Feel free to post a request on the Visual Studio UserVoice site

查看更多
登录 后发表回答