huserben / TfsExtensions

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

Pass boolean buildParameter #225

Open ArianMoinianMicrosoft opened 1 year ago

ArianMoinianMicrosoft commented 1 year ago

Hello How can I pass boolean buildParameter to the triggered build? Best, Arian

huserben commented 1 year ago

Hi @ArianMoinianMicrosoft

what have you tried so far? Could you share a snippet of your pipeline (yaml or a screenshot if you use classic builds).

BuildParameters do not have a type if I remember correctly, so everything will be a string. Template Parameters can be typed, but in the task you still just send true/false and it should be converted automatically.

Hope that helps a bit - otherwise I'd need some more info about the specific use case.

huserben commented 1 year ago

@ArianMoinianMicrosoft Any update on this? As otherwise I'll close due to inactivity.

avang-MT commented 1 year ago

Hi @huserben,

I am having the same exact issue where the downstream template parameters are expecting a boolean parameter type. As a result of expecting a boolean parameter value, the upstream pipeline using the buildTrigger task fails.

Below is the upstream pipeline using the buildTrigger task and failing with template parameters and it's pipeline template definition: image image

Below is the downstream template type parameters the downstream pipeline is expecting: image

As a result, I had to convert all boolean parameter types to string. And I could not use a list of predefined values for string type parameter seen at the bottom:

Thanks in advance.

huserben commented 1 year ago

Hi @avang-MT

to understand correctly. You only had to change the downstream pipeline template types (from boolean to string) and then the triggering worked, without any additional changes?

If so it might be a limitation by the API. Sadly it's not really documented how to use the template parameters, so it's hard for me to tell what could be wrong.

What could help is if you could create a pipeline with a bool parameter and trigger it manually and capture the request that is sent (via the browser network tools). Perhaps we could reverse engineer if there is some specific thing sent if it's a bool value. However, if that would be the case, it would be tricky to handle this in the task, given that it's already quite messy now.

Anyway, if you could provide the request sent via manual triggering it's something to look at. Right now I'm short on time so I don't have any space to check this out in detail myself, so your support would be appreciated. Otherwise, I can try this myself, but you might have to way a bit longer.

Thanks!

avang-MT commented 1 year ago

Hi @avang-MT

to understand correctly. You only had to change the downstream pipeline template types (from boolean to string) and then the triggering worked, without any additional changes?

If so it might be a limitation by the API. Sadly it's not really documented how to use the template parameters, so it's hard for me to tell what could be wrong.

What could help is if you could create a pipeline with a bool parameter and trigger it manually and capture the request that is sent (via the browser network tools). Perhaps we could reverse engineer if there is some specific thing sent if it's a bool value. However, if that would be the case, it would be tricky to handle this in the task, given that it's already quite messy now.

Anyway, if you could provide the request sent via manual triggering it's something to look at. Right now I'm short on time so I don't have any space to check this out in detail myself, so your support would be appreciated. Otherwise, I can try this myself, but you might have to way a bit longer.

Thanks!

That's correct, in order for the downstream pipeline to be properly triggered I had to convert boolean types to string AND remove specified values accepted by the last parameter.

I'll manually test this in a development pipeline and let you know what I observe.

Updates to come.

Thanks.

avang-MT commented 1 year ago

@huserben this is what I am seeing, templateParameters appears to convert the boolean into a string:

Template: image

Payloads (True & False conditions): image image

Is this a limitation by the API perhaps?

huserben commented 1 year ago

Thanks for checking this.

It could still be on "my" side and not the API. I have to dive a bit deeper into the logic and see what is going on. I'll update you here once I have more news. However, I cannot make any predictions about when I will get to it.

So I'm afraid that for the time being you have to stay on your changed template with the strings instead of the boolean. I hope that is ok with you.

avang-MT commented 1 year ago

Thanks for checking this.

It could still be on "my" side and not the API. I have to dive a bit deeper into the logic and see what is going on. I'll update you here once I have more news. However, I cannot make any predictions about when I will get to it.

So I'm afraid that for the time being you have to stay on your changed template with the strings instead of the boolean. I hope that is ok with you.

Thank you. We have a temporary workaround to get us moving forward for the time-being. Keep us posted here for any updates.

Best regards