This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Install the support requests job automatically (#715)
Address NuGet/Engineering#2099
- Loading branch information
1 parent
1c9da41
commit ad6faf5
Showing
4 changed files
with
43 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/NuGet.SupportRequests.Notifications/Scripts/Functions.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Function Install-DailyTask | ||
{ | ||
$trigger = New-ScheduledTaskTrigger -DaysInterval 1 -At "12pm" -Daily | ||
|
||
Install-NuGetScheduledTask $trigger "Support Request Daily Notification" "OnCallDailyNotification.cmd" | ||
} | ||
|
||
Function Install-WeeklyTask | ||
{ | ||
$trigger = New-ScheduledTaskTrigger -Weekly -WeeksInterval 1 -DaysOfWeek Monday -At "12pm" | ||
|
||
Install-NuGetScheduledTask $trigger "Support Requests Weekly Notification" "WeeklySummaryNotification.cmd" | ||
} | ||
|
||
Function Install-NuGetScheduledTask | ||
{ | ||
param($Trigger, $Name, $Command) | ||
|
||
#Action to run as | ||
$cmdExe = [system.environment]::getenvironmentvariable("ComSpec") | ||
$action = New-ScheduledTaskAction -Execute $cmdExe -Argument "/c $PSScriptRoot\$Command" -WorkingDirectory $PSScriptRoot | ||
|
||
#Configure when to stop the task and how long it can run for. In this example it does not stop on idle and uses the maximum possible duration by setting a timelimit of 0 | ||
$settings = New-ScheduledTaskSettingsSet -DontStopOnIdleEnd -ExecutionTimeLimit ([TimeSpan]::Zero) -MultipleInstances IgnoreNew | ||
|
||
#Configure the principal to use for the scheduled task and the level to run as | ||
$principal = New-ScheduledTaskPrincipal -UserID "NT AUTHORITY\SYSTEM" -LogonType ServiceAccount -RunLevel "Highest" | ||
|
||
#Register the new scheduled task | ||
Register-ScheduledTask -TaskName $Name -Action $action -Trigger $Trigger -Principal $principal -Settings $settings -Force | ||
} |
10 changes: 10 additions & 0 deletions
10
src/NuGet.SupportRequests.Notifications/Scripts/PostDeploy.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
. .\Functions.ps1 | ||
|
||
## The daily task is broken right now due to Pin | ||
# Write-Host Register the daily scheduled task | ||
# Install-DailyTask | ||
# Write-Host Registered the daily scheduled task | ||
|
||
Write-Host Register the weekly scheduled task | ||
Install-WeeklyTask | ||
Write-Host Registered the weekly scheduled task |