MethodsAndPractices / vsteam

PowerShell module for accessing Azure DevOps Services and Azure DevOps Server (formerly VSTS or TFS)
https://methodsandpractices.github.io/vsteam-docs/
MIT License
445 stars 155 forks source link

Get-VSTeamBuildDefinition will not return definitions that DO NOT have an agent pool #383

Closed aspiringtfsguru closed 3 years ago

aspiringtfsguru commented 3 years ago

Steps to reproduce

If a build definition does not have an agent pool assigned (it can happen), those definitions will not get returned.

Set-VSTeamAccount -PersonalAccessToken *************************************************
Get-VSTeamBuildDefinition -ProjectName *********

Expected behavior

Lists all build definitions for project specified.

Actual behavior

Exception calling ".ctor" with "2" argument(s): "Object reference not set to an instance of an object."
At C:\Users\slandsaw\Documents\WindowsPowerShell\Modules\VSTeam\7.1.3\vsteam.functions.ps1:3468 char:16
+ ...             $objs += [vsteam_lib.BuildDefinition]::new($item, $Projec ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : NullReferenceException

Environment data

OS

Server

> Get-VSTeamAPIVersion
Name                           Value                                                                                                                                                                                                                             
----                           -----                                                                                                                                                                                                                             
Packaging                      6.0-preview                                                                                                                                                                                                                       
Version                        VSTS                                                                                                                                                                                                                              
ServiceEndpoints               5.0-preview                                                                                                                                                                                                                       
HierarchyQuery                 5.1-preview                                                                                                                                                                                                                       
Graph                          6.0-preview                                                                                                                                                                                                                       
Pipelines                      5.1-preview                                                                                                                                                                                                                       
TaskGroups                     6.0-preview                                                                                                                                                                                                                       
ExtensionsManagement           6.0-preview                                                                                                                                                                                                                       
Git                            5.1                                                                                                                                                                                                                               
VariableGroups                 5.1-preview.1                                                                                                                                                                                                                     
Core                           5.1                                                                                                                                                                                                                               
Release                        5.1                                                                                                                                                                                                                               
DistributedTaskReleased        5.1                                                                                                                                                                                                                               
MemberEntitlementManagement    6.0-preview                                                                                                                                                                                                                       
Tfvc                           5.1                                                                                                                                                                                                                               
Processes                      6.0-preview                                                                                                                                                                                                                       
Policy                         5.1                                                                                                                                                                                                                               
Build                          5.1                                                                                                                                                                                                                               
DistributedTask                6.0-preview  
> $PSVersionTable
Name                           Value                                                                                                                                                                                                                             
----                           -----                                                                                                                                                                                                                             
PSVersion                      5.1.18362.1171                                                                                                                                                                                                                    
PSEdition                      Desktop                                                                                                                                                                                                                           
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                                                                           
BuildVersion                   10.0.18362.1171                                                                                                                                                                                                                   
CLRVersion                     4.0.30319.42000                                                                                                                                                                                                                   
WSManStackVersion              3.0                                                                                                                                                                                                                               
PSRemotingProtocolVersion      2.3                                                                                                                                                                                                                               
SerializationVersion           1.1.0.1 
aspiringtfsguru commented 3 years ago

Here is an example snippet of a build definition that gets return and one that does not.

This build definition has an agent pool that is not null and it gets returned:

    "queue": {
        "_links": {
            "self": {
                "href": "https://dev.azure.com/**************/_apis/build/Queues/377"
            }
        },
        "id": 377,
        "name": "On-Prem",
        "url": "https://dev.azure.com/**************/_apis/build/Queues/377",
        "pool": {
            "id": 10,
            "name": "On-Prem"
        }
    }

This build definition has an agent pool that IS null and it does not get returned:


    "queue": {
        "_links": {
            "self": {
                "href": "https://dev.azure.com/**************/_apis/build/Queues/203"
            }
        },
        "id": 203,
        "url": "https://dev.azure.com/**************/_apis/build/Queues/203",
        "pool": null
    }

EDIT: Had a typo that needed fixing.

aspiringtfsguru commented 3 years ago

Now that I think about it, I should probably just catch that on my side.

SebastianSchuetze commented 3 years ago

The question actually is when this comes actually up?

Is it only when you create a pipeline with the json, the API or over the GUI.

In the case of the latter, I could imagine the this should return it.