From 0528c762bf9d1508a5cba76890c3323039d92fb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20S=20Sch=C3=BCtze?= Date: Sat, 3 Sep 2022 22:21:10 +0200 Subject: [PATCH 1/3] fixed a problem that prevented the module to load on module load the default project is set as well as the given project queried to check if the project exists this causes a default exception since on module load no set-vsteamaccount is set. This is fixed by returning warning messages --- Source/VSTeam.psm1 | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/Source/VSTeam.psm1 b/Source/VSTeam.psm1 index ac3991f4..28f753ec 100644 --- a/Source/VSTeam.psm1 +++ b/Source/VSTeam.psm1 @@ -17,19 +17,34 @@ Set-VSTeamAPIVersion -Target $([vsteam_lib.Versions]::Version) #compare versions and notify user # new versions for the module are only checked if $env:VSTEAM_NO_UPDATE_MESSAGE is not set -if(($env:VSTEAM_NO_UPDATE_MESSAGE -eq $false) -or ($null -eq $env:VSTEAM_NO_UPDATE_MESSAGE)) { +if (($env:VSTEAM_NO_UPDATE_MESSAGE -eq $false) -or ($null -eq $env:VSTEAM_NO_UPDATE_MESSAGE)) { _checkForModuleUpdates -ModuleVersion ([version][vsteam_lib.Versions]::ModuleVersion) -ErrorAction Continue } # display custom message if set and not $true -if(($env:VSTEAM_NO_MODULE_MESSAGES -eq $false) -or ($null -eq $env:VSTEAM_NO_MODULE_MESSAGES)) { +if (($env:VSTEAM_NO_MODULE_MESSAGES -eq $false) -or ($null -eq $env:VSTEAM_NO_MODULE_MESSAGES)) { _showModuleLoadingMessages -ModuleVersion ([version][vsteam_lib.Versions]::ModuleVersion) -ErrorAction Continue } # Check to see if the user stored the default project in an environment variable if ($null -ne $env:TEAM_PROJECT) { - # Make sure the value in the environment variable still exisits. - if (Get-VSTeamProject | Where-Object ProjectName -eq $env:TEAM_PROJECT) { - Set-VSTeamDefaultProject -Project $env:TEAM_PROJECT + + + # if not account and pat is set, then do not try to set the default project + if ($null -eq $env:TEAM_PAT -and $null -eq $env:TEAM_ACCT) { + Write-Warning "No PAT or Account set. You must set the environment variables TEAM_PAT or TEAM_ACCT before loading the module to use the default project." + } + else { + # set vsteam account to initialize given variables properly + Set-VSTeamAccount -Account $env:TEAM_ACCT -PersonalAccessToken $env:TEAM_PAT + # Make sure the value in the environment variable still exisits. + if (Get-VSTeamProject | Where-Object ProjectName -eq $env:TEAM_PROJECT) { + Set-VSTeamDefaultProject -Project $env:TEAM_PROJECT + } + else { + Write-Warning "The default project '$env:TEAM_PROJECT' stored in the environment variable TEAM_PROJECT does not exist." + } } + + } \ No newline at end of file From 1edd59e7615fd5ed8bdffb384170aedc1ac39976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20S=20Sch=C3=BCtze?= Date: Sat, 3 Sep 2022 22:28:32 +0200 Subject: [PATCH 2/3] added changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 552e5d97..4b72cd51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog ## 7.9.0 + +Merged [Pull Request](https://github.com/MethodsAndPractices/vsteam/pull/480) from [Sebastian Schütze](https://github.com/SebastianSchuetze) the following: +- fixed a problem that prevented the module to load [#467](https://github.com/MethodsAndPractices/vsteam/issues/467) + Merged [Pull Request](https://github.com/MethodsAndPractices/vsteam/pull/468) from [Michael19842](https://github.com/Michael19842) the following: - Added parameter `Templateparameter` for queue new build with custom template parameters From ae0487d751275921d898c02e3ba43db0e6b2f658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20S=20Sch=C3=BCtze?= Date: Sun, 4 Sep 2022 13:15:43 +0200 Subject: [PATCH 3/3] fixed a bug which does not recognize 'Version' parameter --- Source/Private/common.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Private/common.ps1 b/Source/Private/common.ps1 index 59194165..6474acb9 100644 --- a/Source/Private/common.ps1 +++ b/Source/Private/common.ps1 @@ -269,7 +269,7 @@ function _getApiVersion { [parameter(ParameterSetName = 'Service', Mandatory = $true, Position = 0)] [ValidateSet('Build', 'Release', 'Core', 'Git', 'DistributedTask', 'DistributedTaskReleased', 'VariableGroups', 'Tfvc', - 'Packaging', 'MemberEntitlementManagement', + 'Packaging', 'MemberEntitlementManagement','Version', 'ExtensionsManagement', 'ServiceEndpoints', 'Graph', 'TaskGroups', 'Policy', 'Processes', 'HierarchyQuery', 'Pipelines', 'Billing', 'Wiki', 'WorkItemTracking')] [string] $Service,