From 0b695d04b84078ec76af71292e522f08de4a1a15 Mon Sep 17 00:00:00 2001 From: Aaron Jensen Date: Wed, 12 Feb 2020 11:44:33 -0800 Subject: [PATCH 1/3] Improving BuildMasterAutomation import speed by merging functions into .psm1 file. --- BuildMasterAutomation/BuildMasterAutomation.psd1 | 5 ++--- BuildMasterAutomation/BuildMasterAutomation.psm1 | 10 ++++++++-- whiskey.yml | 6 ++++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/BuildMasterAutomation/BuildMasterAutomation.psd1 b/BuildMasterAutomation/BuildMasterAutomation.psd1 index 2762f96..e77553d 100644 --- a/BuildMasterAutomation/BuildMasterAutomation.psd1 +++ b/BuildMasterAutomation/BuildMasterAutomation.psd1 @@ -12,7 +12,7 @@ RootModule = 'BuildMasterAutomation.psm1' # Version number of this module. - ModuleVersion = '0.8.0' + ModuleVersion = '0.9.0' # ID used to uniquely identify this module GUID = 'cc5a1865-e5f8-45f2-b0d3-317a1611a965' @@ -144,8 +144,7 @@ The BuildMasterAutomation module is a PowerShell module for working with BuildMa # ReleaseNotes of this module ReleaseNotes = @' -* Added support for BuildMaster 6.1.17. Fixed an issue where environments created with `New-BMEnvironment` are disabled/inactive in that version. -* Added `Inactive` switch to `New-BMEnvironment` to create inactive/disabled environments. The default is to create active/enabled environments. +* Improved import speed by merging all functions into the module's .psm1 file. '@ } # End of PSData hashtable diff --git a/BuildMasterAutomation/BuildMasterAutomation.psm1 b/BuildMasterAutomation/BuildMasterAutomation.psm1 index 6f73a99..68d36d0 100644 --- a/BuildMasterAutomation/BuildMasterAutomation.psm1 +++ b/BuildMasterAutomation/BuildMasterAutomation.psm1 @@ -1,5 +1,11 @@ Add-Type -AssemblyName 'System.Web' -Get-ChildItem -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Functions') -Filter '*.ps1' | - ForEach-Object { . $_.FullName } \ No newline at end of file +$functionsDir = Join-Path -Path $PSScriptRoot -ChildPath 'Functions' +if( (Test-Path -Path $functionsDir -PathType Container) ) +{ + foreach( $item in (Get-ChildItem -Path $functionsDir -Filter '*.ps1') ) + { + . $item.FullName + } +} diff --git a/whiskey.yml b/whiskey.yml index 8013719..5ff764a 100644 --- a/whiskey.yml +++ b/whiskey.yml @@ -22,6 +22,12 @@ Build: OnlyDuring: Build Path: init.ps1 +- MergeFile: + Path: BuildMasterAutomation\Functions\*.ps1 + DestinationPath: BuildMasterAutomation\BuildMasterAutomation.psm1 + DeleteSourceFiles: true + TextSeparator: "$(NewLine)$(NewLine)" + - Pester4: Path: Tests\*.Tests.ps1 Verbose: false From 4ca617428baf75a0f1dd6a67425160d95f7d45be Mon Sep 17 00:00:00 2001 From: Aaron Jensen Date: Wed, 12 Feb 2020 12:28:57 -0800 Subject: [PATCH 2/3] Upgrading to 6.1.25 (6.2.3 is totally borked; Pipelines_* native API is missing. --- BuildMasterAutomation/BuildMasterAutomation.psd1 | 2 ++ BuildMasterAutomation/Functions/New-BMServerRole.ps1 | 2 +- init.ps1 | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/BuildMasterAutomation/BuildMasterAutomation.psd1 b/BuildMasterAutomation/BuildMasterAutomation.psd1 index e77553d..f342514 100644 --- a/BuildMasterAutomation/BuildMasterAutomation.psd1 +++ b/BuildMasterAutomation/BuildMasterAutomation.psd1 @@ -145,6 +145,8 @@ The BuildMasterAutomation module is a PowerShell module for working with BuildMa # ReleaseNotes of this module ReleaseNotes = @' * Improved import speed by merging all functions into the module's .psm1 file. +* Updating to support BuildMaster 6.1.25. +* Fixed: New-BMServerRole requires a request body in BuildMaster 6.1.25. '@ } # End of PSData hashtable diff --git a/BuildMasterAutomation/Functions/New-BMServerRole.ps1 b/BuildMasterAutomation/Functions/New-BMServerRole.ps1 index 45fb4a6..5292d14 100644 --- a/BuildMasterAutomation/Functions/New-BMServerRole.ps1 +++ b/BuildMasterAutomation/Functions/New-BMServerRole.ps1 @@ -35,5 +35,5 @@ function New-BMServerRole Use-CallerPreference -Cmdlet $PSCmdlet -SessionState $ExecutionContext.SessionState $encodedName = [uri]::EscapeDataString($Name) - Invoke-BMRestMethod -Session $Session -Name ('infrastructure/roles/create/{0}' -f $encodedName) -Method Post + Invoke-BMRestMethod -Session $Session -Name ('infrastructure/roles/create/{0}' -f $encodedName) -Method Post -Body '{}' } \ No newline at end of file diff --git a/init.ps1 b/init.ps1 index f095220..bed0a13 100644 --- a/init.ps1 +++ b/init.ps1 @@ -27,7 +27,7 @@ Set-StrictMode -Version 'Latest' $runningUnderAppVeyor = (Test-Path -Path 'env:APPVEYOR') -$version = '6.1.17' +$version = '6.1.25' Write-Verbose -Message ('Testing BuildMaster {0}' -f $version) $sqlServer = $null $installerPath = 'SQL' From ea25dd2c0300c51827f950473b2af2691eba91c2 Mon Sep 17 00:00:00 2001 From: Aaron Jensen Date: Wed, 12 Feb 2020 13:09:33 -0800 Subject: [PATCH 3/3] Only merge functions into .psm1 file on the build server. --- whiskey.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/whiskey.yml b/whiskey.yml index 5ff764a..3b3a2e0 100644 --- a/whiskey.yml +++ b/whiskey.yml @@ -23,6 +23,7 @@ Build: Path: init.ps1 - MergeFile: + OnlyBy: BuildServer Path: BuildMasterAutomation\Functions\*.ps1 DestinationPath: BuildMasterAutomation\BuildMasterAutomation.psm1 DeleteSourceFiles: true