huserben / TfsExtensions

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

"##[error]Cannot read property 'id' of null" when running in release pipeline #193

Closed neilhuiz closed 3 years ago

neilhuiz commented 3 years ago

I'm trying to use a release pipeline to trigger a YAML pipeline and keep getting the error ##[error]Cannot read property 'id' of null when attempting to use OAuth authentication and passing in $(System.AccessToken). Here's the YAML view of the settings as output by the release definition UI.

steps:
- task: benjhuser.tfs-extensions-build-tasks.trigger-build-task.TriggerBuild@3
  displayName: 'Trigger pipeline: 47228386'
  inputs:
    buildDefinition: 47228386
    queueBuildForUserThatTriggeredBuild: false
    waitForQueuedBuildsToFinish: true
    waitForQueuedBuildsToFinishRefreshTime: 120
    authenticationMethod: 'OAuth Token'
    password: '$(System.AccessToken)'

I suppose that I could use a PAT but would rather not. The practice of using PAT for access to our Azure DevOps is frowned upon by our security teams. Any help here would be hugely appreciated. More complete task output (redacted) is below:

2021-09-28T20:03:01.2048570Z ##[section]Starting: Trigger pipeline: 47228386
2021-09-28T20:03:01.2291732Z ==============================================================================
2021-09-28T20:03:01.2292066Z Task         : Trigger Build
2021-09-28T20:03:01.2292536Z 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.
2021-09-28T20:03:01.2292990Z Version      : 3.2.2
2021-09-28T20:03:01.2293193Z Author       : Benjamin Huser
2021-09-28T20:03:01.2293383Z Help         : 
2021-09-28T20:03:01.2293603Z ==============================================================================
2021-09-28T20:03:02.4667459Z Using current Team Project
2021-09-28T20:03:02.4668749Z Team Project: {REDACTED} with ID {REDACTED}
2021-09-28T20:03:02.4669996Z Using current Collection Url
2021-09-28T20:03:02.4674740Z Server URL: https://{REDACTED}.visualstudio.com/
2021-09-28T20:03:02.4676266Z Using following Authentication Method: OAuth Token
2021-09-28T20:03:02.4683232Z Using OAuth Access Token
2021-09-28T20:03:02.7999033Z Provided team project was guid.
2021-09-28T20:03:02.8000365Z Using same branch as source version: refs/heads/dev/build/ci
2021-09-28T20:03:03.0408911Z No build definition with name 47228386 found...
2021-09-28T20:03:03.0410622Z Specified build name is a number - will treat as build id...
2021-09-28T20:03:03.1722392Z ##[error]Cannot read property 'id' of null
2021-09-28T20:03:03.1819398Z ##[section]Finishing: Trigger pipeline: 47228386
neilhuiz commented 3 years ago

Update: I tried using PAT authentication and that resulted in the same error message.

neilhuiz commented 3 years ago

Ack! I spent the last couple hours looking at this and now I see that the build definition Id I provided is a typo and that the output even says that! My apologies.

huserben commented 3 years ago

Hi @neilhuiz

I'm glad you could find it out. The issues that pop up and get solved while I'm asleep are the best ones :-)

In case you run into more problems, have a question or some proposal for improvement, feel free to open another issue.