huserben / TfsExtensions

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

Unable to get triggerBuild working: [cannot read property 'value' of undefined] #31

Closed stevehoek closed 6 years ago

stevehoek commented 6 years ago

Hi, We're trying to use this extension and it always fails with a generic error:

2017-10-02T15:27:39.6936769Z ##[section]Starting: Trigger a new build of 3DEngine-Players-Mac, 3DEngine-Players-Windows
...
2017-10-02T16:12:10.1178200Z Using current Team Project Url
2017-10-02T16:12:10.1178200Z Path to Server: https://tfs.xyz.net/xyz/Platform
2017-10-02T16:12:10.1178200Z Using Personal Access Token
2017-10-02T16:12:10.1188190Z Build shall be triggered for same user that triggered current build: Dev Name
2017-10-02T16:12:10.1188190Z Triggered Build will use the same source version: C199041
2017-10-02T16:12:10.1188190Z Using same branch as source version: $/Platform
2017-10-02T16:12:10.1188190Z Will trigger build with following demands:
**2017-10-02T16:12:10.1248190Z ##[error]Cannot read property 'value' of undefined**

We have simplified the options that we originally wanted to use, and it seems like it is failing in the actual triggerBuild call... perhaps in the REST wrapper that tries to get the Id from the build name?

We are trying to trigger 2 builds, one for Mac and the other for Windows, but even when we just list the Windows build as the build to trigger we get the same error.

Any ideas on what we can check?

huserben commented 6 years ago

Hi @stevehoek

thanks for reporting this. Could you please tell me which version of the Task you are using and if you are using VSTS or on prem TFS (and the version if you use on prem).

Thanks :-)

stevehoek commented 6 years ago

Hi @huserben

We are using the latest version of the task (2.2.1) with an on-prem TFS 2017 server

Thanks, -Steve

huserben commented 6 years ago

Hi Steve

hmm ok, usually this is a problem with authentication (however the last version should have improved the logging of that...maybe i missed something there.)

As you are using a personal access tokens, are you sure the correct rights are set for it? It needs Build (read and execute).

Otherwise how does your configuration of the Task look like? Are you using any conditions or awaiting the build to finish?

Edit: I just uploaded a new version of the task and tried to improve logging a bit, so maybe you could try again and we would see a bit more information. If it is really a problem of Authentication, you could try to for now switch to the OAuth Token and see if this works, at least we would have located the problem. In case you wanna use the OAuth Token you would need to enable the build to access the OAuth token (see documentation of the task).

stevehoek commented 6 years ago

Hi @huserben

No, we don't have much setup on the task anymore - originally we did but we stripped things out in an effort to debug what was happening.

Our thinking was also that it could have something to do with authentication. We added a PAT of the user who configured the agents, and that user should be part of the Build Admin group so I assume they have Build (read/execute) rights. We will check further.

Here is our task configuration:

image

huserben commented 6 years ago

Hi

ok, however you can set different scopes for all the PAT's you define: grafik

Maybe there something went sideways (for me now the default was "All Scopes" which should work). Other problem could be that the token has expired, this you could see in the token overview if it's acctive or revoked or expired.

The configuration really doesn't look too special, so I would try once with the OAuth token to verify it's really the autentication, then we could try and further investigate why the PAT wasn't working or figure out what else it could :-)

stevehoek commented 6 years ago

Hi @huserben

The PAT scope was the issue! Thanks for the help! We were using the same PAT we generated for managing the Agent Pools, so it did not have the build read/execute right.

While I have your attention... it would be nice if each build could have its own depend list... we have Windows and Mac builds, and they need different pre-req dependencies.

Cheers, -Steve

huserben commented 6 years ago

Hi @stevehoek

ok very good to know.

If you want to have different dependencies/conditions I would simply create 2 tasks instances. Solving this in one task would require some special syntax and then it gets quite complex to configure.

Is there something that would speak against having two tasks instead of one?