@@ -54,6 +54,8 @@ Write-Host "Retrieved $ssm_config_path/agent_mode parameter - ($agent_mode)"
54
54
$token_path = $parameters.where ( {$_.Name -eq " $ssm_config_path /token_path" }).value
55
55
Write-Host " Retrieved $ssm_config_path /token_path parameter - ($token_path )"
56
56
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 )"
57
59
58
60
if ($enable_cloudwatch_agent -eq " true" )
59
61
{
@@ -107,9 +109,14 @@ foreach ($group in @("Administrators", "docker-users")) {
107
109
Set-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System - Name ConsentPromptBehaviorAdmin - Value 0 - Force
108
110
Write-Host " Disabled User Access Control (UAC)"
109
111
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
+ }
113
120
114
121
Write-Host " Starting the runner as user $run_as "
115
122
@@ -123,7 +130,11 @@ ConvertTo-Json -InputObject $jsonBody | Set-Content -Path "$pwd\.setup_info"
123
130
124
131
Write-Host " Installing the runner as a service"
125
132
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
+ }
127
138
$trigger = Get-CimClass " MSFT_TaskRegistrationTrigger" - Namespace " Root/Microsoft/Windows/TaskScheduler"
128
139
Register-ScheduledTask - TaskName " runnertask" - Action $action - Trigger $trigger - User $username - Password $password - RunLevel Highest - Force
129
140
Write-Host " Starting the runner in persistent mode"
0 commit comments