$(Build.SourceVersion) not giving latest change set number sometimes

912 Views Asked by At

In the build pipeline task(Power Shell), I try to retrieve the value of $(Build.SourceVersion) assuming it will give the latest change set number that triggered the build. But sometimes it is giving the previous change set number.

Can we force to update this variable to have the latest change set number? or Do we have any other alternative to get the latest changeset number that triggered the build?

I haven’t made any changes to the variable. In the pipeline I have added a power shell script task which accesses the environment variable called “$env:ChangeSetNumber” this environment variable is declared in Environment Variables section in the task as shown in the below image which points to “$(Build.SourceVersion)”

enter image description here

The value of $(Build.SourceVersion) sometimes returns the previous change set number rather than the change set number that triggered the build.

Requirement is to get changeset number that triggered the build.

1

There are 1 best solutions below

3
Vivek Jaiswal On

Try using the following alternative:

$(system.pullRequest.sourceCommitId)