huserben / TfsExtensions

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

Select stages to run with `TriggerBuild` task #221

Open gabrielmbmb opened 1 year ago

gabrielmbmb commented 1 year ago

Hi! I'm trying to trigger pipeline A from pipeline B using the TriggerBuild task and I was wondering if it is possible to select the stages to run on pipeline A, as you would do when triggering it from the Azure DevOps web user interface. It is possible?

huserben commented 1 year ago

Hi @gabrielmbmb Sorry for the late response, I'm currently on vacation.

It's currently not possible to do this with the task. It might be supported by the library & API, but I have not checked. What you could use as a workaround would be to use template parameters that enable/disable stages. It's ugly but should work, as I don't know if the asked for feature will ever be added to the task.

If the API supports it you could also think about writing a small script (eg in Powershell) - as long as your usecase is simple that could work too

gabrielmbmb commented 1 year ago

Hey! Thanks for the response @huserben. Yes, the API supports skipping stages with the body parameter stagesToSkip (seen in Azure Devops docs). I've created a small script sending the request directly to the API as a workaround. Do you contemplate adding this body parameter to TfsRestService and later to the extension? It would be a nice feature to have. Thanks, and nice job with the extension! :)

huserben commented 1 year ago

Nice - glad that for now you have something working. I'll try to check it when I'm back, if the effort is small enough (sounds like it :-) ) I'll add it, but let's see. As I'm not using the plain requests but MS Azure DevOps Node API I hope to get the parameter there as well.

Lets leave this issue open and I'll update you accordingly once I have more news.

huserben commented 1 year ago

Quick update, I've checked now the Azure Devops Node Api I could not find any support for stagesToSkip so far (see https://github.com/microsoft/azure-devops-node-api/blob/1032df89f37f85940bfc321fe34510af90ba03a5/api/BuildApi.ts#L1030 and https://github.com/microsoft/azure-devops-node-api/blob/1032df89f37f85940bfc321fe34510af90ba03a5/api/interfaces/BuildInterfaces.ts#L155).

I can try to to set the "stagesToSkip" property on the build object anyway and see if that works - if not we'd need to wait for this to be available in the library from microsoft (perhaps creating an issue/PR for this later on).

I'll keep you posted.