TfsExtensions icon indicating copy to clipboard operation
TfsExtensions copied to clipboard

Select stages to run with `TriggerBuild` task

Open gabrielmbmb opened this issue 2 years ago • 4 comments

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?

gabrielmbmb avatar Jul 05 '22 10:07 gabrielmbmb

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

huserben avatar Jul 11 '22 09:07 huserben

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! :)

gabrielmbmb avatar Jul 11 '22 09:07 gabrielmbmb

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 avatar Jul 11 '22 10:07 huserben

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.

huserben avatar Jul 14 '22 06:07 huserben