huserben / TfsExtensions

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

Trigger child build with spaces or in folder #8

Closed JohnHennesey closed 7 years ago

JohnHennesey commented 7 years ago

I did some experimentation and it seems having a child build in a folder or a child build with spaces trips it up. It is not able to get the build definition id - the output is:

2017-05-23T20:41:22.3446235Z Queue new Build for definition Dynamic/Dashboard on http://name removed/name removed/name removed/_apis/build/builds?api-version=2.0

2017-05-23T20:41:22.3446235Z { definition: { id: }, sourceBranch: "$/name removed/Utilities/BuildScripts", requestedFor: { id: "92968178-d553-40d1-9495-8383940fef92"}, sourceVersion: "C54247", parameters: "{\"Tst.BranchName\":\"Tip\", \"Tst.CopyToPostBuildDrop\":\"false\"}"}

2017-05-23T20:41:23.0633758Z ##[error]System.Net.WebException: The remote server returned an error: (400) Bad Request.

For the child definition name I tried "/Dynamic/Dashboard", "Dynamic/Dashboard", "Dynamic Dashboard" (moved into root folder), and ultimately what worked was just plain 'ole "Dashboard" in the root.

Being very very new to this I still am learning how to do this whole powershell / build thing - I am not sure how to modify the ps1 to test. My hunch is this line may need some love: $buildDefinitionUrl = "build/definitions?api-version=2.0&name=$($definition)"

Maybe url escape the definition name? Just throwing darts...

Let me know your thoughts - if I can help please let me know.

John

huserben commented 7 years ago

Hi John

what do you exactly mean with a child build? how can you put builds in a subfolder? Can you maybe send me a screenshot of your builds and your configuration of the tasks?

Thanks for your help

JohnHennesey commented 7 years ago

Apologies for not being clear... I think my terminology is incorrect. I refer to the 'parent' as the build definition that uses the trigger build task, and the child as the build that is being triggered. I plan to have a 'master parent' that calls many 'child definitions'. I am on TFS 2017 which allows folders in the build definitions for easy organization. Attached are 4 files - a screen shot of the folders, parent, child and output. Thanks again for your help!

++++++++++++++++++++++++++ folders

++++++++++++++++++++++++++ parent

++++++++++++++++++++++++++ child

++++++++++++++++++++++++++ results

huserben commented 7 years ago

Hi John

thanks for the clarification, now it's more clear to me :-) I will have a look into it, but it can't be that the space is an issue, my test builds actually have spaces and there it works correct. Probably I can take a look over the weekend and provide you some feedback or fix.

huserben commented 7 years ago

Hi again

so I checked again and the spaces are handled correctly by the Task. The issue you are facing seems to be that you specified the path including the folder name, which actually is not supported. The script looks for the build definition by name to get out its ID. The name of the build definition is not influenced by the folder it is stored in, that's really only for grouping the definitions. So basically just specify the name of the build definition and everything will be fine. Of course this means you cannot have two build definitions with the same name but in different folders, the script then would probably just take the first build definition it finds...that's a restriction that we probably will not get rid of soon, as the other option I could see would be to specify the ID of the Build Definition directly, which obviously is not a nice solution at all.

I hope this answer helps, if you have any further questions or inputs please let me know.

JohnHennesey commented 7 years ago

Thank you for the fast feedback! I don't think having a unique name on the build is a showstopper - I'll still take the awesomeness you have created!
Thanks for your help - John

huserben commented 7 years ago

No Problem, thanks for the kind words :-)

I'll then close this issue - if you have any other feature requests or problems don't hesitate to create a new issue, every feedback is good feedback ;-)