huserben / TfsExtensions

Extensions for TFS 2015+ such as custom Widgets (require TFS 2017) and Build Tasks
MIT License
45 stars 22 forks source link

Problem building dependent projects on a TFS agent #44

Closed inehme closed 6 years ago

inehme commented 6 years ago

I am ruuning TFS 2015 on premise; I have 1 TFS agents and a TFS pool. I am building two projects A and B. Project A reference Project B. I tried to use your Trigger Build Task without any success because Project A wait for Project B to complete build, but there is 1 pool. Is there a workaround that allow the project dependencies to biuld the without creating a second/new TFS agent?

huserben commented 6 years ago

Hi @inehme

so just for me to summarize and see if I got it correct: You have two builds (A and B) where you start building A and in there you trigger B?

If so, do you need to wait for B to complete (meaning do you have something in Build A that needs something from B like artifacts or so?) Otherwise you can just disable the option "Wait till the triggered builds are finished" under Advanced Configuration.

inehme commented 6 years ago

Hi, That's correct build A needs artifacts from build B.

huserben commented 6 years ago

Ok, so what you could to is simply to split Build A into two, the first part which does everything till you trigger Build B. Just make sure that you store the Triggered Build ID as a variable and do not wait for B to finish here.

The second part of Build A that needs to be executed after Build B finsihed has to go into a new Build Definition (let's call it C) This one you trigger as well from Build A at the very end (again, it does not have to wait to finish it in there). In order now to await finishing Build B in your new Build C, add as a first task the WaitForBuildToFinish Task. There you should have all the options you have as well for the trigger build task when awaiting a build to finish. This task however needs the build ID of build B as an input, so you have to add a new Variable in Build C that is called "TriggeredBuildIds" and make sure it is settable at queue time. Now when you trigger Build C from Build A specify it in the Parameters section to be passed to Build C: \"TriggeredBuildIds:\" \"$(TriggeredBuildIds)\"

So I hope that was somewhat understandable to you. Bottom line is you cannot await any build if you only have one build agent, but you can work around that by splitting it up into multiple builds.

huserben commented 6 years ago

Hi @inehme

did you manage to solve your issue or can I assist you in any way?

inehme commented 6 years ago

Hi, All good thanks for your response.