From ea668fbaabb06d2b1c49c706c22f86677446e2a7 Mon Sep 17 00:00:00 2001 From: clr2of8 Date: Mon, 2 Oct 2023 16:23:51 -0600 Subject: [PATCH 1/5] add atomic runner hooks --- Public/Invoke-AtomicRunner.ps1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Public/Invoke-AtomicRunner.ps1 b/Public/Invoke-AtomicRunner.ps1 index 5109049..7a34f38 100755 --- a/Public/Invoke-AtomicRunner.ps1 +++ b/Public/Invoke-AtomicRunner.ps1 @@ -192,11 +192,15 @@ function Invoke-AtomicRunner { } if ($null -ne $tr) { + if (Get-Command 'Invoke-AtomicRunnerPreAtomicHook' -errorAction SilentlyContinue) { Invoke-AtomicRunnerPreAtomicHook } Invoke-AtomicTestFromScheduleRow $tr + if (Get-Command 'Invoke-AtomicRunnerPostAtomicHook' -errorAction SilentlyContinue) { Invoke-AtomicRunnerPostAtomicHook } Write-Host -Fore cyan "Sleeping for $SleepTillCleanup seconds before cleaning up"; Start-Sleep -Seconds $SleepTillCleanup # Cleanup after running test + if (Get-Command 'Invoke-AtomicRunnerPreAtomicCleanupHook' -errorAction SilentlyContinue) { Invoke-AtomicRunnerPreAtomicCleanupHook } Invoke-AtomicTestFromScheduleRow $tr $true + if (Get-Command 'Invoke-AtomicRunnerPostAtomicCleanupHook' -errorAction SilentlyContinue) { Invoke-AtomicRunnerPostAtomicCleanupHook } } else { LogRunnerMsg "Could not find Test: $guid in schedule. Please update schedule to run this test." From 78c6442e0e3d7edb9891d9f61a03edd77b636f17 Mon Sep 17 00:00:00 2001 From: clr2of8 Date: Mon, 2 Oct 2023 18:45:48 -0600 Subject: [PATCH 2/5] add atomic runner hooks --- Public/Invoke-AtomicRunner.ps1 | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Public/Invoke-AtomicRunner.ps1 b/Public/Invoke-AtomicRunner.ps1 index 7a34f38..29e089b 100755 --- a/Public/Invoke-AtomicRunner.ps1 +++ b/Public/Invoke-AtomicRunner.ps1 @@ -1,5 +1,4 @@ . "$PSScriptRoot\Invoke-RunnerScheduleMethods.ps1" - function Invoke-AtomicRunner { [CmdletBinding( SupportsShouldProcess = $true, @@ -59,6 +58,8 @@ function Invoke-AtomicRunner { $tr.InputArgs = ConvertFrom-StringData -StringData $theArgs } $sc = $tr.AtomicsFolder + if ($Cleanup) { if (Get-Command 'Invoke-AtomicRunnerPreAtomicCleanupHook' -errorAction SilentlyContinue) { Invoke-AtomicRunnerPreAtomicCleanupHook } } + elseif (-not($ShowDetails -or $CheckPrereqs -or $ShowDetailsBrief -or $GetPrereqs)) { if (Get-Command 'Invoke-AtomicRunnerPreAtomicHook' -errorAction SilentlyContinue) { Invoke-AtomicRunnerPreAtomicHook } } #Run the Test based on if scheduleContext is 'private' or 'public' if (($sc -eq 'public') -or ($null -eq $sc)) { Invoke-AtomicTest $tr.Technique -TestGuids $tr.auto_generated_guid -InputArgs $tr.InputArgs -TimeoutSeconds $tr.TimeoutSeconds -ExecutionLogPath $artConfig.execLogPath -PathToAtomicsFolder $artConfig.PathToPublicAtomicsFolder @htvars -Cleanup:$Cleanup -supressPathToAtomicsFolder @@ -66,6 +67,8 @@ function Invoke-AtomicRunner { elseif ($sc -eq 'private') { Invoke-AtomicTest $tr.Technique -TestGuids $tr.auto_generated_guid -InputArgs $tr.InputArgs -TimeoutSeconds $tr.TimeoutSeconds -ExecutionLogPath $artConfig.execLogPath -PathToAtomicsFolder $artConfig.PathToPrivateAtomicsFolder @htvars -Cleanup:$Cleanup -supressPathToAtomicsFolder } + if ($Cleanup) { if (Get-Command 'Invoke-AtomicRunnerPostAtomicCleanupHook' -errorAction SilentlyContinue) { Invoke-AtomicRunnerPostAtomicCleanupHook } } + elseif (-not($ShowDetails -or $CheckPrereqs -or $ShowDetailsBrief -or $GetPrereqs)) { if (Get-Command 'Invoke-AtomicRunnerPostAtomicHook' -errorAction SilentlyContinue) { Invoke-AtomicRunnerPostAtomicHook } } } function Rename-ThisComputer ($tr, $basehostname) { @@ -170,7 +173,6 @@ function Invoke-AtomicRunner { } return } - # exit if file stop.txt is found If (Test-Path $artConfig.stopFile) { LogRunnerMsg "exiting script because $($artConfig.stopFile) does exist" @@ -192,15 +194,11 @@ function Invoke-AtomicRunner { } if ($null -ne $tr) { - if (Get-Command 'Invoke-AtomicRunnerPreAtomicHook' -errorAction SilentlyContinue) { Invoke-AtomicRunnerPreAtomicHook } Invoke-AtomicTestFromScheduleRow $tr - if (Get-Command 'Invoke-AtomicRunnerPostAtomicHook' -errorAction SilentlyContinue) { Invoke-AtomicRunnerPostAtomicHook } Write-Host -Fore cyan "Sleeping for $SleepTillCleanup seconds before cleaning up"; Start-Sleep -Seconds $SleepTillCleanup # Cleanup after running test - if (Get-Command 'Invoke-AtomicRunnerPreAtomicCleanupHook' -errorAction SilentlyContinue) { Invoke-AtomicRunnerPreAtomicCleanupHook } Invoke-AtomicTestFromScheduleRow $tr $true - if (Get-Command 'Invoke-AtomicRunnerPostAtomicCleanupHook' -errorAction SilentlyContinue) { Invoke-AtomicRunnerPostAtomicCleanupHook } } else { LogRunnerMsg "Could not find Test: $guid in schedule. Please update schedule to run this test." From 2928c730d486cbe8e906788a1ca797be51076be9 Mon Sep 17 00:00:00 2001 From: clr2of8 Date: Mon, 2 Oct 2023 18:48:41 -0600 Subject: [PATCH 3/5] add atomic runner hooks --- Public/Invoke-AtomicRunner.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Public/Invoke-AtomicRunner.ps1 b/Public/Invoke-AtomicRunner.ps1 index 29e089b..2915143 100755 --- a/Public/Invoke-AtomicRunner.ps1 +++ b/Public/Invoke-AtomicRunner.ps1 @@ -1,4 +1,5 @@ . "$PSScriptRoot\Invoke-RunnerScheduleMethods.ps1" + function Invoke-AtomicRunner { [CmdletBinding( SupportsShouldProcess = $true, @@ -173,6 +174,7 @@ function Invoke-AtomicRunner { } return } + # exit if file stop.txt is found If (Test-Path $artConfig.stopFile) { LogRunnerMsg "exiting script because $($artConfig.stopFile) does exist" From 9f852bd6c0c67f19040e8aabb12aa007b7e94899 Mon Sep 17 00:00:00 2001 From: clr2of8 Date: Mon, 2 Oct 2023 18:49:41 -0600 Subject: [PATCH 4/5] add atomic runner hooks --- Public/Invoke-AtomicRunner.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Public/Invoke-AtomicRunner.ps1 b/Public/Invoke-AtomicRunner.ps1 index 2915143..cafa852 100755 --- a/Public/Invoke-AtomicRunner.ps1 +++ b/Public/Invoke-AtomicRunner.ps1 @@ -174,7 +174,7 @@ function Invoke-AtomicRunner { } return } - + # exit if file stop.txt is found If (Test-Path $artConfig.stopFile) { LogRunnerMsg "exiting script because $($artConfig.stopFile) does exist" From fa69e428ea156a6ac685003ac12ad78f84238a9e Mon Sep 17 00:00:00 2001 From: clr2of8 Date: Mon, 2 Oct 2023 18:50:12 -0600 Subject: [PATCH 5/5] add atomic runner hooks --- Public/Invoke-AtomicRunner.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Public/Invoke-AtomicRunner.ps1 b/Public/Invoke-AtomicRunner.ps1 index cafa852..8fea56c 100755 --- a/Public/Invoke-AtomicRunner.ps1 +++ b/Public/Invoke-AtomicRunner.ps1 @@ -174,7 +174,7 @@ function Invoke-AtomicRunner { } return } - + # exit if file stop.txt is found If (Test-Path $artConfig.stopFile) { LogRunnerMsg "exiting script because $($artConfig.stopFile) does exist"