Closed jrdodds closed 4 years ago
Hi @jrdodds
Thanks for your feedback. When making the request the parameters should be ignored and thus let TFS handle it.
I checked the docs but couldn't see anything about the variables beeing empty.
I quickly checked online and found out that it seems that TFS behaves like, it apparently only populates the fields when the builds are queued automatically (see this discussion in Stack Overflow.
So I fear this seems to be a limitation of TFS in that case.
Hi @jrdodds
Could you work around your issue? If the API is behaving like this it's hard to properly work around that, so we do not get unexpected results...
If you have any idea on how to solve it from the Task itself let me know, then I could assess whether it's possible or not (and within what timeframe).
Closed due to inactivity
Hi , i also have same issue..use case i trigger build from release build definition using trigger build task and these two variables are empty.. is there any way i can get it populated? Thank you
Hi @Ajmal18
sorry for the late reply.
So you mean the variables are not set in the target build that you have triggered right? What you could try is to to pass them as parameters via the TriggerBuildTask.
So something like: Build.SourceBranch: $(Build.SourceBranch), Build.SourceBranchName: $(Build.SourceBranchName)
I have not tried it, but I guess it's worth a shot. If this doesn't work directly you could also pass it with a different parameter that you define as variable in the target branch and that is settable at queue time (for example CustomSourceBranch and CustomSourceBranchName). Then as a first step you write some kind of script that checks whether those parameters where set and the Build.SourceBranch and SourceBranchName are empty, if so you can take the value of CustomSourceBranch and set it to Build.SourceBranch.
I know that's not ideal but at least that's a way I could see working.
v3 of Trigger Build Task with a TFVC repository with on-premise TFS 2017. 1.) Uncheck 'Use same source branch as triggered build'. 2.) Leave 'Defines Branch that shall be used' empty.
In the resulting triggered build, the predefined build variables Build.SourceBranch and Build.SourceBranchName are empty. The expectation is that these variables should be set from the value of the default branch.
A work around is to explictly provide the branch in the 'Defines Branch that shall be used' field but this is not DRY.
Is this an issue in the API?
Thanks