@@ -194,6 +194,79 @@ def run_script
194194exit $(cat ~/build.sh.exit)
195195EOF
196196 session . exec ( "GUEST_API_URL=%s bash ~/wrapper.sh" % guest_api_url ) { exit_exec? }
197+ elsif payload [ :config ] [ :os ] == 'windows' && Hash === payload [ :config ] [ :windows ] && payload [ :config ] [ :windows ] [ :run_in_session1 ]
198+ session . upload_file ( "~/buildWrapper.sh" , <<EOF % [ Travis ::Worker ::VirtualMachine . config [ :username ] , Travis ::Worker ::VirtualMachine . config [ :password ] ] )
199+ #!/bin/bash
200+ #curl -X POST -d '{"message":"Interactive runner started"}' $GUEST_API_URL/logs
201+ WIN_HOME_DIR=`cygpath -adw ~`
202+ PS1_FILE=`echo $WIN_HOME_DIR | sed s'|\\ \\ \\ \\ |\\ \\ \\ \\ \\ \\ \\ \\ |g'`\\ \\ runPSWrapper.ps1
203+
204+ /cygdrive/c/Tools/PsExec.exe -u "%s" -p "%s" -acceptEula -h -i 1 powershell -file "$PS1_FILE"
205+
206+ if [ -f ~/build.sh.exit ] ; then
207+ exit $(cat ~/build.sh.exit)
208+ else
209+ echo "Runner script was probably not executed, returning 1";
210+ exit 1;
211+ fi
212+
213+ EOF
214+
215+ session . upload_file ( "~/runPSWrapper.ps1" , <<EOF % guest_api_url )
216+ $GUEST_API_URL="%s";
217+ [System.Reflection.Assembly]::LoadWithPartialName("System.Net");
218+ [System.Reflection.Assembly]::LoadWithPartialName("System.Web.Extensions");
219+ $ser = New-Object System.Web.Script.Serialization.JavaScriptSerializer;
220+
221+ $json = $ser.serialize(@{message= "`n`nMinttyRunner started`n`n"});
222+ $bytes = [System.Text.Encoding]::ASCII.GetBytes($json);
223+ $cl = new-object System.Net.WebClient;
224+ $cl.uploaddata("$GUEST_API_URL/logs", $bytes);
225+
226+ $p = new-object system.diagnostics.process;
227+ $p.StartInfo.UseShellExecute = $false;
228+ $p.StartInfo.CreateNoWindow = $true;
229+ $p.StartInfo.FileName = "c:\\ cygwin\\ bin\\ mintty.exe";
230+ $p.StartInfo.Arguments = "-l - --exec /bin/bash -l -c 'exec /bin/bash ~/build.sh'";
231+ $p.StartInfo.RedirectStandardError = $p.StartInfo.RedirectStandardOutput = $true;
232+
233+ $block = {
234+ try
235+ {
236+ $hash = @{message = $event.SourceEventArgs.Data};
237+ $json = $ser.Serialize($hash);
238+ $cl = new-object System.Net.WebClient;
239+ $bytes = [System.Text.Encoding]::ASCII.GetBytes($json);
240+ $cl.uploaddata("$GUEST_API_URL/logs", $bytes);
241+ }
242+ catch
243+ {
244+ }
245+ }
246+
247+ Register-ObjectEvent -InputObject $p -EventName OutputDataReceived -Action $block -SourceIdentifier OutputReader | Out-Null;
248+ $p.Start() | out-null;
249+ $p.BeginOutputReadLine();
250+ while(-not $p.HasExited)
251+ {
252+ sleep 1;
253+ };
254+ if($p.StandardError -ne $null)
255+ {
256+ $p.StandardError.ReadToEnd()|Out-Host;
257+ };
258+ Unregister-Event -SourceIdentifier OutputReader;
259+ $p.WaitForExit();
260+
261+ $json = $ser.serialize(@{message= "`n`nMinttyRunner finished`n`n"});
262+ $bytes = [System.Text.Encoding]::ASCII.GetBytes($json);
263+ $cl = new-object System.Net.WebClient;
264+ $cl.uploaddata("$GUEST_API_URL/logs", $bytes);
265+
266+ exit $($p.ExitCode);
267+
268+ EOF
269+ session . exec ( "GUEST_API_URL=%s bash --login ~/buildWrapper.sh" % guest_api_url ) { exit_exec? }
197270 else
198271 session . exec ( "GUEST_API_URL=%s bash --login ~/build.sh" % guest_api_url ) { exit_exec? }
199272 end
0 commit comments