Skip to content

Commit

Permalink
fixed a problem that prevented the module to load (#480) and a parame…
Browse files Browse the repository at this point in the history
…ter problem when getting current set API versions

* 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

* fixed a bug which does not recognise 'Version' parameter
  • Loading branch information
SebastianSchuetze authored Sep 4, 2022
1 parent 10024b0 commit 0cd0c46
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion Source/Private/common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
25 changes: 20 additions & 5 deletions Source/VSTeam.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
}


}

0 comments on commit 0cd0c46

Please sign in to comment.