19
19
#>
20
20
param (
21
21
[Parameter (Mandatory = $true )]
22
- [string ]$ADOToken
22
+ [string ] $AccessToken
23
23
)
24
24
25
25
function InitializeRequiredPackages {
@@ -37,7 +37,6 @@ function InitializeRequiredPackages {
37
37
$requiredPackages = @ (
38
38
@ { PackageName = " Newtonsoft.Json" ; PackageVersion = " 13.0.2" ; DllName = " Newtonsoft.Json.dll" },
39
39
@ { PackageName = " YamlDotNet" ; PackageVersion = " 13.2.0" ; DllName = " YamlDotNet.dll" }
40
-
41
40
)
42
41
43
42
$requiredPackages | ForEach-Object {
@@ -51,71 +50,73 @@ function InitializeRequiredPackages {
51
50
52
51
# get wiki content
53
52
$username = " "
54
- $password = $ADOToken
53
+ $password = $AccessToken
55
54
$pair = " {0}:{1}" -f ($username , $password )
56
55
$bytes = [System.Text.Encoding ]::ASCII.GetBytes($pair )
57
56
$token = [System.Convert ]::ToBase64String($bytes )
58
57
$headers = @ {
59
58
Authorization = " Basic {0}" -f ($token )
60
59
}
61
60
62
- $response = Invoke-RestMethod ' https://dev.azure.com/azclitools/internal/_apis/wiki/wikis/internal.wiki/pages?path=/Service%20Contact%20List&includeContent=true' - Headers $headers
61
+ $response = Invoke-RestMethod ' https://dev.azure.com/azclitools/internal/_apis/wiki/wikis/internal.wiki/pages?path=/Service%20Contact%20List&includeContent=true' - Headers $headers - ErrorAction Stop
63
62
$contactsList = ($response.content -split " \n" ) | Where-Object { $_ -like ' |*' } | Select-Object - Skip 2
64
63
65
- $idxServiceTeamLabel = 2
66
- $idxPSNotifyGithubHandler = 6
67
- $serviceContacts = [System.Collections.Generic.SortedList [System.String , PSCustomObject ]]::new()
68
-
69
- foreach ($contacts in $contactsList ) {
70
- $items = $contacts -split " \|"
71
- $colServiceTeamLabel = $items [$idxServiceTeamLabel ]
72
- if (! [string ]::IsNullOrWhiteSpace($colServiceTeamLabel )) {
73
- $serviceTeamLabel = $colServiceTeamLabel.Trim ()
74
- $colPSNotifyGithubHandler = $items [$idxPSNotifyGithubHandler ]
75
-
76
- if (! [string ]::IsNullOrWhiteSpace($colPSNotifyGithubHandler )) {
77
- $psNotifyGithubHandler = $colPSNotifyGithubHandler.Trim ()
78
- [array ]$mentionees = $psNotifyGithubHandler.Split (" ," , [StringSplitOptions ]::RemoveEmptyEntries) | ForEach-Object {
79
- $_.Trim ()
80
- }
81
-
82
- $serviceContacts.Add ($serviceTeamLabel , [PSCustomObject ]@ {
83
- if = @ (
84
- [PSCustomObject ]@ {
85
- or = @ (
86
- [PSCustomObject ]@ {
87
- labelAdded = [PSCustomObject ]@ {
88
- label = ' Service Attention'
89
- }
90
- },
91
- [PSCustomObject ]@ {
92
- labelAdded = [PSCustomObject ]@ {
93
- label = $serviceTeamLabel
64
+ if ($null -ne $contactsList ) {
65
+ $idxServiceTeamLabel = 2
66
+ $idxPSNotifyGithubHandler = 6
67
+ $serviceContacts = [System.Collections.Generic.SortedList [System.String , PSCustomObject ]]::new()
68
+
69
+ foreach ($contacts in $contactsList ) {
70
+ $items = $contacts -split " \|"
71
+ $colServiceTeamLabel = $items [$idxServiceTeamLabel ]
72
+ if (! [string ]::IsNullOrWhiteSpace($colServiceTeamLabel )) {
73
+ $serviceTeamLabel = $colServiceTeamLabel.Trim ()
74
+ $colPSNotifyGithubHandler = $items [$idxPSNotifyGithubHandler ]
75
+
76
+ if (! [string ]::IsNullOrWhiteSpace($colPSNotifyGithubHandler )) {
77
+ $psNotifyGithubHandler = $colPSNotifyGithubHandler.Trim ()
78
+ [array ]$mentionees = $psNotifyGithubHandler.Split (" ," , [StringSplitOptions ]::RemoveEmptyEntries) | ForEach-Object {
79
+ $_.Trim ()
80
+ }
81
+
82
+ $serviceContacts.Add ($serviceTeamLabel , [PSCustomObject ]@ {
83
+ if = @ (
84
+ [PSCustomObject ]@ {
85
+ or = @ (
86
+ [PSCustomObject ]@ {
87
+ labelAdded = [PSCustomObject ]@ {
88
+ label = ' Service Attention'
89
+ }
90
+ },
91
+ [PSCustomObject ]@ {
92
+ labelAdded = [PSCustomObject ]@ {
93
+ label = $serviceTeamLabel
94
+ }
94
95
}
96
+ )
97
+ },
98
+ [PSCustomObject ]@ {
99
+ hasLabel = [PSCustomObject ]@ {
100
+ label = ' Service Attention'
101
+ }
102
+ },
103
+ [PSCustomObject ]@ {
104
+ hasLabel = [PSCustomObject ]@ {
105
+ label = $serviceTeamLabel
95
106
}
96
- )
97
- },
98
- [PSCustomObject ]@ {
99
- hasLabel = [PSCustomObject ]@ {
100
- label = ' Service Attention'
101
- }
102
- },
103
- [PSCustomObject ]@ {
104
- hasLabel = [PSCustomObject ]@ {
105
- label = $serviceTeamLabel
106
107
}
107
- }
108
- )
109
- then = @ (
110
- [PSCustomObject ]@ {
111
- mentionUsers = [ PSCustomObject ] @ {
112
- mentionees = $ mentionees
113
- replyTemplate = ' Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc ${mentionees}. '
114
- assignMentionees = ' False '
108
+ )
109
+ then = @ (
110
+ [ PSCustomObject ] @ {
111
+ mentionUsers = [PSCustomObject ]@ {
112
+ mentionees = $mentionees
113
+ replyTemplate = ' Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc ${ mentionees}. '
114
+ assignMentionees = ' False '
115
+ }
115
116
}
116
- }
117
- )
118
- })
117
+ )
118
+ } )
119
+ }
119
120
}
120
121
}
121
122
}
0 commit comments