huserben / TfsExtensions

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

Not able to trigger a pipeline in different project with build parameters #249

Closed jithintraderev closed 9 months ago

jithintraderev commented 9 months ago

I am trying to trigger a pipeline in project 1, from a release pipeline in project2. I am not able to trigger the pipeline with build variables. but it can be triggered without any parameters.

I tried moving the pipeline in project1 to the project 2 space and everything works fine(with and without release builds)

Have you noticed any bug in the extension which limit the triggering of a pipeline in Project 1 from Project 2 with build parameters.

I have enabled debug logs and there isnt anything useful that I could find. Also am using development branch for triggering build which is availbale 2023-09-19T17:13:30.2805323Z Using Custom Team Project 2023-09-19T17:13:30.2805844Z Team Project: ABC 2023-09-19T17:13:30.2807944Z Using Custom Collection Url 2023-09-19T17:13:30.2808534Z Server URL: https://aaa.visualstudio.com/ 2023-09-19T17:13:30.2809118Z Using following Authentication Method: Personal Access Token 2023-09-19T17:13:30.2809773Z Using Personal Access Token 2023-09-19T17:13:30.6174947Z Provided team project was no guid, trying to resolve ID via API... 2023-09-19T17:13:30.8579800Z Found id for team project ABC: ********* 2023-09-19T17:13:30.8580634Z Context is Release - using Release Environment Variables 2023-09-19T17:13:30.8581173Z Build shall be triggered for same user that triggered current Release: Jithin Jose 2023-09-19T17:13:30.8581847Z Will trigger build with following parameters: testenv:"stg",lang:"ca",sendSlackNotification:"True",isRemoteRun:"True" 2023-09-19T17:13:31.0068583Z No build definition with name 4173 found... 2023-09-19T17:13:31.0069442Z Specified build name is a number - will treat as build id... 2023-09-19T17:13:31.0069914Z Found parameter testenv with value: "stg" 2023-09-19T17:13:31.0070340Z Found parameter lang with value: "ca" 2023-09-19T17:13:31.0070803Z Found parameter sendSlackNotification with value: "True" 2023-09-19T17:13:31.0071258Z Found parameter isRemoteRun with value: "True" 2023-09-19T17:13:31.6515588Z Error during request (1/5) 2023-09-19T17:13:31.6516558Z Error message: Error: Could not queue the build because there were validation errors or warnings. 2023-09-19T17:13:31.6518247Z Will wait 1 seconds before retrying request... 2023-09-19T17:13:33.5268528Z Error during request (2/5) 2023-09-19T17:13:33.5269238Z Error message: Error: Could not queue the build because there were validation errors or warnings. 2023-09-19T17:13:33.5269861Z Will wait 2 seconds before retrying request... 2023-09-19T17:13:36.1814175Z Error during request (3/5) 2023-09-19T17:13:36.1815353Z Error message: Error: Could not queue the build because there were validation errors or warnings. 2023-09-19T17:13:36.1816170Z Will wait 4 seconds before retrying request... 2023-09-19T17:13:40.9478393Z Error during request (4/5) 2023-09-19T17:13:40.9479066Z Error message: Error: Could not queue the build because there were validation errors or warnings. 2023-09-19T17:13:40.9479654Z Will wait 8 seconds before retrying request... 2023-09-19T17:13:49.6901416Z Error during request (5/5) 2023-09-19T17:13:49.6908180Z Error message: Error: Could not queue the build because there were validation errors or warnings. 2023-09-19T17:13:49.6909950Z ##[debug]task result: Failed 2023-09-19T17:13:49.6946923Z ##[error]Request failed after 5 tries - see error messages in the log

image
huserben commented 9 months ago

Hi @jithintraderev

I see you opened the issue and then closed it, does it mean that you've solved it? If so, would you mind sharing what you did to solve it, in case others face the same problem?

jithintraderev commented 9 months ago

I still couldn't solve the issue. My initial assumption was that the extension couldn't communicate from project1 to project2. But even after creating a pipeline in project 2, I am not able to trigger a pipeline with build params in project2.

Are you aware of any project settings in ado that restricts triggering builds with build variables?

This is my current setup I have a release pipeline in project2 that uses the extension to trigger a downstream job

huserben commented 9 months ago

Hi

hmm that is really strange. So the exact same snippet works in one project but not the other?

You trigger this from a release pipeline, right? This is also what you did in project 1 where it works with parameters?

jithintraderev commented 9 months ago

Yes. The downstream pipelines yaml is identical and I am just changing the Project and build definition in the extension UI to trigger them.

As part of debugging I created release pipeline in project 1 and 2 and I am able to trigger the downstream job in project 1 with build params every time from both release pipelines.

Whenever I had build params added as below, the downstream job in project 2 isn't triggered. But same setup works for the downstream job in project 1

image
jithintraderev commented 9 months ago

After days of troubleshooting, I could finally solve the issue. Seems like ADO added a new feature to limit triggering pipelines with variables that were not defined in the pipelines. https://learn.microsoft.com/en-us/azure/devops/pipelines/security/inputs?view=azure-devops#limit-variables-that-can-be-set-at-queue-time

If anyone have similar issue, add the build variables that you are trying to pass from upstream job as variables in the downstream job and you guys should be good.

image
huserben commented 9 months ago

Hi @jithintraderev

glad you found the issue. For me it still doesn't make much sense on why it behaved the way it did, but if it works now I'm happy. Thank you for raising this and also taking the time to share your solution!