huserben / TfsExtensions

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

TriggerBuild@4 does not support runtime parameters #253

Open ChristoWolf opened 4 months ago

ChristoWolf commented 4 months ago

Hi @huserben!

So unless I am doing something wrong, it looks like that your TriggerBuild@4 task does not support runtime parameters when passing buildParameters. More precisely, when the pipeline-to-be-triggered takes such parameters, and the triggering pipeline attempts to pass arguments to those via the task's buildParameters, but seemingly fails:

Using current Team Project
Team Project: <redacted>
Using current Collection Url
Server URL: <redacted>
Using following Authentication Method: Personal Access Token
Using Personal Access Token
Provided team project was guid.
Context is Build - using Build Environment Variables
Build shall be triggered for same user that triggered current build: <redacted>
Will trigger build with following demands:
<redacted>
Build Queue was specified as string: <redacted>
Found id of queue <redacted>
Will trigger build in following agent queue: <redacted>
Will trigger build with following parameters: <redacted parameters>
Found parameter <redacted>
Found parameter <redacted>
Error during request (1/5)
Error message: Error: Could not queue the build because there were validation errors or warnings.
Will wait 1 seconds before retrying request...
Error during request (2/5)
Error message: Error: Could not queue the build because there were validation errors or warnings.
Will wait 2 seconds before retrying request...
Error during request (3/5)
Error message: Error: Could not queue the build because there were validation errors or warnings.
Will wait 4 seconds before retrying request...
Error during request (4/5)
Error message: Error: Could not queue the build because there were validation errors or warnings.
Will wait 8 seconds before retrying request...
Error during request (5/5)
Error message: Error: Could not queue the build because there were validation errors or warnings.

If using classic queue-time variables instead, everything works as expected, the arguments are passed correctly.

huserben commented 4 months ago

Hi @ChristoWolf

yes, you are correct, buildParameters are just for the classic queue-time variables. But you can use the templateParameters argument, and it should work as expected 😉

Please let me know if that solves your problem.

ChristoWolf commented 4 months ago

Thanks @huserben! Ah yes, now I understand this, had a bit of a tough time understanding the docs for that.

huserben commented 4 months ago

Great to hear it worked.

Well, I was struggling to find how to use it...I did not do a good job of documenting this. It's something that certainly could be improved.

On the other hand it's a bit annoying, as I have to create a "new version" of the extension just to update the documentation...

Anyway if I find some time this weekend I'll at least update what's visible on github so that the change would be included in the next release...

Thanks for reporting this!

madhavagrawal17 commented 2 months ago

@huserben, I am also facing the same issue. Can you please put a screenshot of how you are passing the template parameters to make it work ? Getting this error when using the template parameters: image

huserben commented 1 month ago

Hi @madhavagrawal17

sorry for the dealy in the response. Would you mind sharing your configuration to so I can see what might be the issue.

Are you using buildParameters or templateParameters ?

madhavagrawal17 commented 1 month ago

@huserben, I am using the tempalteParameters. Here is the screenshot of my configuration:

image

huserben commented 1 month ago

Thanks @madhavagrawal17

could you also share the full logs from the failing pipeline (the parts till the error occurs - ideally as text) and the definition of the pipeline you are triggering?

I see you are using the classic view, not yaml. Just to be sure: the triggered pipeline is defined in yaml, right?

madhavagrawal17 commented 1 month ago

@huserben, We are using the classic release pipeline but we are triggering the yaml pipeline, Here is the definition:

image

Logs attached here: Logs_triggerbuildpipeline.txt

huserben commented 1 month ago

@madhavagrawal17

Thanks for the additional info. I can see that you are triggering the pipeline from a release definition. Also I can see the following error in the logs: 2024-05-01T22:02:42.0233840Z Error message: Error: The repository Office in project {projectId}could not be retrieved. Verify the name and credentials being used.

I've never tested the combination of a release pipeline triggering a yaml pipeline, so some questions to dig deeper:

Edit: Actually there are certain unsupported things when using a release pipeline, as in the docs it's stating:

When the task is used within a release definition, certain configuration options might not work properly if there is no build artifact linked (e.g. for Use same User that triggered Build and Use same Branch). The task was designed only with build definitions in mind, in case you need it to work in Release Definitions without any builds linked please open a new issue on [issues](https://github.com/huserben/TfsExtensions/issues) and explain your problem to see whether there is a workaround

I can see that you are using "Use same user that triggered the build" and "use same branch". Try to manually specify this instead of using the checkbox. That would also be in line with the error you're getting.

madhavagrawal17 commented 1 month ago

@huserben, Thanks for your response. When I trigger the release pipeline without the template parameters then everything works fine. I see the issue only when I pass the template parameter. I also tried with disabling "Use same user that triggered the build" and "use same branch" and specifying it manually but it gave me the same error.

huserben commented 4 weeks ago

Hi @madhavagrawal17

ok, thanks for confirming this. What authentication method are you using? The OAuth token from the pipeline or a personal access token?

The error you're getting in the logs seem to indicate some issue with an included/template repository you are including in the yaml: The repository in project could not be retrieved

See also StackOverflow. Could you check this out and see if this might apply to you? While it's odd it's only happening when you are using template parameters, the error does not look like it's related to this...

madhavagrawal17 commented 3 weeks ago

@huserben, Thanks for providing me the link but I am not using any template reference in my build yaml. So, I think it won't be related to the link you have provided. Not sure why it only fails with the template parameters.