huserben / TfsExtensions

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

Trigger Build task running against a fork throws ##[error]Cannot read property 'id' of null #156

Closed BruceHaley closed 3 years ago

BruceHaley commented 3 years ago

Task version 3.1.7. Pipeline was triggered by a PR, and is running against a fork of the repo. Build being triggered is in the same project, and is being referenced by ID. If I change the reference to build name, it throws ##[error]Did not find any build definition with this name: BotBuilder-Samples-DotNet-CI-PR. Authentication is OAuth token.

If the pipeline is running against a branch which is not a fork, Trigger Build runs without error.

How can I overcome this problem?

Below is the complete log. Attached is a screen shot of the settings. 2020-11-17 18_33_25-Samples-CI-PR-Pipelines-Runner - Azure DevOps Services

\============================================================================== Task : Trigger Build Description : This tasks allows to trigger a new Build (add it to the queue) as part of a Build Definition. It contains as well some conditions that can be applied, for example if the last build of certain definition was successful or not. Version : 3.1.7 Author : Benjamin Huser Help : \============================================================================== Using current Team Project Team Project: SDK_v4 with ID 86659c66-c9df-418a-a371-7de7aed35064 Using current Collection Url Server URL: https://fuselabs.visualstudio.com/ Using following Authentication Method: OAuth Token Trying to fetch authentication token from system... Using OAuth 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: Microsoft.VisualStudio.Services.TFS Source Version: 010c507fae06aedaea1b4318260bdd25850bedfb Triggered Build will use the same source version: 010c507fae06aedaea1b4318260bdd25850bedfb Using same branch as source version: refs/pull/2934/merge Will trigger build with following parameters: TriggeringBuildReason: PullRequest, TriggeringPRNumber: 2934, TriggeringPRTitle: [QnA Maker bot samples] Configurable default answer - nodejs, csharp , TriggeringPRUrl: https://github.com/microsoft/BotBuilder-Samples/pull/2934 Will fail the task if a condition is not fulfilled. No build definition with name 1199 found... Specified build name is a number - will treat as build id... Found parameter TriggeringBuildReason with value: PullRequest Found parameter TriggeringPRNumber with value: 2934 Found parameter TriggeringPRTitle with value: [QnA Maker bot samples] Configurable default answer - nodejs, csharp Found parameter TriggeringPRUrl with value: https://github.com/microsoft/BotBuilder-Samples/pull/2934

[error]Cannot read property 'id' of null

BruceHaley commented 3 years ago

I solved this problem by switching authentication from OAuth to using a Personal Access Token.

PS: Wait for Build(s) task needed a PAT also. Otherwise: ##[error]Cannot read property 'definition' of null