Alezis
Alezis

Reputation: 2759

TFS 2015. the $(var.SourceLocation) variable is not available at gated-check in

We are migrating from old XAML build definition to new TFS 2015 build. In old we have gated-check in that is working fine. In new one we have such option on "Triggers" tab. However I want use commit ID that trigger build. The variable $(Build.SourceVersion) is responsible for this, but for gated-check in it is not being set. It looks right, because commit was not accepted by TFS yet.

The question is how to grab this commit ID either during gated-check in or following CI ?

Should I create just another build for gated check-in that just compile our solution and only if succeeded will trigger CI ?

Upvotes: 0

Views: 191

Answers (2)

Alezis
Alezis

Reputation: 2759

So far, I end up with not clean workaround, but it were accepted by our management. I created two build definitions: one for gated-check in, one for CI. Once someone checked in something gated check-in fires. If it completed successfully, CI build would be triggered. Please note corresponding checkbox on UI:

gated CI

This is not so clean solution, but it works for me.

Upvotes: 0

Cece Dong - MSFT
Cece Dong - MSFT

Reputation: 31075

There is no way to get the changeset id that hasn't checked in during gated check-in. Please check the screenshot below, checking in gated changes is in the very last step in the build process, which can't be controlled. After the build completes, the variable $(Build.SourceVersion) will update automatically. So we are not able to get the changeset id that hasn't checked in until the build completes.

enter image description here

You would need to use TFS REST API to get the build that has completed, then fetch the "sourceVersion":

GET http://{instance}/DefaultCollection/{project}/_apis/build/builds/{buildId}?api-version={version}

Upvotes: 1

Related Questions