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 -Type not considered correctly #87

Closed KaiWalter closed 5 years ago

KaiWalter commented 6 years ago

Steps to reproduce

I extended integration test

      It 'Add-VSTeamBuildDefinition should add a build definition' {
         Add-VSTeamBuildDefinition -ProjectName $newProjectName -InFile $tmpBuildDef1
         $buildDef = Get-VSTeamBuildDefinition -ProjectName $newProjectName
         $buildDef | Should Not Be $null
      }

      It 'Add-VSTeamBuildDefinition should add another build definition' {
         Add-VSTeamBuildDefinition -ProjectName $newProjectName -InFile $tmpBuildDef2
         $buildDefs = Get-VSTeamBuildDefinition -ProjectName $newProjectName
         $buildDefs.Count | Should Be 2
      }

      It 'Get-VSTeamBuildDefinition by Type "build" should return 2 build definitions' {
         $buildDefs = Get-VSTeamBuildDefinition -ProjectName $newProjectName -Type build
         $buildDefs.Count | Should Be 2
      }

      It 'Get-VSTeamBuildDefinition by Type "xaml" should return no build definitions' {
         $buildDefs = Get-VSTeamBuildDefinition -ProjectName $newProjectName -Type xaml
         $buildDefs.Count | Should Be 0
      }

to check that the correct build definitions types are returned.

Expected behavior

I expected that these tests pass

Actual behavior

      [+] Get-VSTeamBuildDefinition by Type "build" should return 2 build definitions 8.15s
      [-] Get-VSTeamBuildDefinition by Type "xaml" should return no build definitions 469ms
        Expected 0, but got 2.
        213:          $buildDefs.Count | Should Be 0
        at Invoke-LegacyAssertion, C:\Program Files\WindowsPowerShell\Modules\Pester\4.4.0\Functions\Assertions\Should.ps1: line 188
        at <ScriptBlock>, C:\Users\y1wle\src\Kai\vsteam\integration\test\010_projects.Tests.ps1: line 213

Discussion

@DarqueWarrior the API call does not consider the type always returns 2 build definitions:

         $resp = _callAPI -ProjectName $ProjectName -Area build -Resource definitions -Version $([VSTeamVersions]::Build) `
            -QueryString @{type = $type; name = $filter; includeAllProperties = $true}

Can you confirm this? Is that the intended behavior of the API? Are buildDefinition.type "build" == "xaml"?

DarqueWarrior commented 6 years ago

Looking into it now

KaiWalter commented 5 years ago

How can I help here?

DarqueWarrior commented 5 years ago

Looking at the AzD API type is not even supported because it does not have XAML builds anymore. This is a TFS only switch. I am using TFS 2017 to do some more testing.

DarqueWarrior commented 5 years ago

OK. At this point I think we just remove the Type parameter. I can't find on Docs.com any mention of this parameter anymore. It might have been there a long time ago but as of 4.1 which is the oldest version on docs it is not there.

nschonni commented 5 years ago

The "previous-apis" are over here https://docs.microsoft.com/en-us/azure/devops/integrate/previous-apis/build/definitions?view=tfs-2017 It is pretty annoying that they're not all in one place ☹️

DarqueWarrior commented 5 years ago

Nice! I had no idea where the old APIs were. Thanks.

DarqueWarrior commented 5 years ago

My version of TFS 2017 is running version 3.x of the API. At this point I am going to drop support for the 2.0 API that includes that parameter.