Skip to content

Commit 63ff192

Browse files
committed
fix: adding missing argument --jitconfig for ephemeral windows runners (#3950)
1 parent 808222f commit 63ff192

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

modules/runners/templates/start-runner.ps1

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ Write-Host "Retrieved $ssm_config_path/agent_mode parameter - ($agent_mode)"
5454
$token_path=$parameters.where( {$_.Name -eq "$ssm_config_path/token_path"}).value
5555
Write-Host "Retrieved $ssm_config_path/token_path parameter - ($token_path)"
5656

57+
$enable_jit_config=$parameters.where( {$_.Name -eq "$ssm_config_path/enable_jit_config"}).value
58+
Write-Host "Retrieved $ssm_config_path/enable_jit_config parameter - ($enable_jit_config)"
5759

5860
if ($enable_cloudwatch_agent -eq "true")
5961
{
@@ -107,9 +109,14 @@ foreach ($group in @("Administrators", "docker-users")) {
107109
Set-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name ConsentPromptBehaviorAdmin -Value 0 -Force
108110
Write-Host "Disabled User Access Control (UAC)"
109111

110-
$configCmd = ".\config.cmd --unattended --name $runner_name_prefix$InstanceId --work `"_work`" $config"
111-
Write-Host "Configure GH Runner as user $run_as"
112-
Invoke-Expression $configCmd
112+
if ($enable_jit_config -eq "true") {
113+
Write-Output "Starting with JIT config -> config.cmd not called"
114+
} else {
115+
Write-Output "Starting without JIT config -> call config.cmd"
116+
$configCmd = ".\config.cmd --unattended --name $runner_name_prefix$InstanceId --work `"_work`" $config"
117+
Write-Host "Configure GH Runner as user $run_as"
118+
Invoke-Expression $configCmd
119+
}
113120

114121
Write-Host "Starting the runner as user $run_as"
115122

@@ -123,7 +130,11 @@ ConvertTo-Json -InputObject $jsonBody | Set-Content -Path "$pwd\.setup_info"
123130

124131
Write-Host "Installing the runner as a service"
125132

126-
$action = New-ScheduledTaskAction -WorkingDirectory "$pwd" -Execute "run.cmd"
133+
if ($enable_jit_config -eq "true") {
134+
$action = New-ScheduledTaskAction -WorkingDirectory "$pwd" -Execute "run.cmd" -Argument "--jitconfig $config"
135+
} else {
136+
$action = New-ScheduledTaskAction -WorkingDirectory "$pwd" -Execute "run.cmd"
137+
}
127138
$trigger = Get-CimClass "MSFT_TaskRegistrationTrigger" -Namespace "Root/Microsoft/Windows/TaskScheduler"
128139
Register-ScheduledTask -TaskName "runnertask" -Action $action -Trigger $trigger -User $username -Password $password -RunLevel Highest -Force
129140
Write-Host "Starting the runner in persistent mode"

0 commit comments

Comments
 (0)