Robin
Robin

Reputation: 2328

TFS build get label if exists else latest?

I'm specifying a label in the "Get Version" property of a TFS 2012 build definition:

Get Version: LMyLabel

However, if MyLabel doesn't exist, the build fails with this error message:

Exception Message: TF14064: Could not find label MyLabel@*. (type LabelNotFoundException)

How can I configure the build to default to the latest code if MyLabel doesn't exist?

Upvotes: 2

Views: 806

Answers (1)

Just TFS
Just TFS

Reputation: 4787

You would have to customise the template.

Locate the Get Workspace Activity

Get Workspace Activity

Note that it's properties has the GetVersion Argument

Get Workspace Activity Properties

Now add a Try Catch Activity, where the current Get Workspace Activity resides

try catch

Copy the original Get Workspace Activity to the Try.

Copy the Get Workspace Activity and place it in the catch, Set the catch to Exception

Catch of Try Catch Activity

In the Properties of you Get Workspace Activity set the VersionOverride value to be blank.

This should now try and Donwload the source for a label you supply, if that label is not present then the catch should be hit and you should then download the latest code.

This was done on the fly and may need some minor tweeking!

Upvotes: 3

Related Questions