Reputation: 2185
Currently, I have three solutions that have corresponding builds and they produce three artifacts:
CommonSolution -> BuildA -> Common.dll (output drops into a nuget feed)
ProgramSolution -> BuildB -> Program.exe
ServiceSolution -> BuildC -> Service.svc
Program.exe and Service.svc both consume the Common.dll via a nuget feed and it should be the exact same version.
Currently all the builds are isolated and so the CommonSolution is built. Then the Common nuget is updated manually in the Program/Service, and then they are built.
In TFS, is there any way such that if BuildB is trigged, it automatically triggers BuildA first, then the Common nuget is updated and consumed in BuildB and BuildC, and the two builds are triggered?
Or are there any other setups that would be more suitable?
Upvotes: 1
Views: 189
Reputation: 51073
When you edit your build configuration, go to the Triggers tab and enable Continuous Integration. There you can define path filters and specify the path to your solution folder, so the build will only be triggered when changes are checked in to that distinct path.
In your case, only the CommonSolution changed, the dll will be updated. Then just need to chain build B and build C.
For the latest version of TFS- Azure DevOps Server 2019, we do have a build-in feature: Build completion triggers
Large products have several components that are dependent on each other. These components are often independently built. When an upstream component (a library, for example) changes, the downstream dependencies have to be rebuilt and revalidated.
In situations like these, add a build completion trigger to run your build upon the successful completion of the triggering build. You can select any other build in the same project.
For TFS version 2018 and previous, there are two ways to run another build in your current build.
Option 1: add PowerShell task in your current build definition to queue another build by REST API
Assume another build id is 5, so you can add PowerShell task with the script:
$body = @{
definition = @{
id = 5
}
}
$Uri = "http://account.visualstudio.com/DefaultCollection/project/_apis/build/builds?api-version=2.0"
$buildresponse = Invoke-RestMethod -Method Post -UseDefaultCredentials -ContentType application/json -Uri $Uri -Body (ConvertTo-Json $body)
Option 2: install related extension in Market place There are some extensions you can install for your on-premise TFS server, then you can add the task to queue another build. such as Queue Build(s) Task, Trigger New Build, Queue New Build etc.
is there any way such that if BuildB is trigged, it automatically triggers BuildA first
So,you could add a step to trigger Build A during the process when running Build B.
Upvotes: 2