Esempio n. 1
0
        public DeployAgentResult Deploy(DeployAgentData deployAgentData)
        {
            var    errorOccurred = true;
            string output        = string.Empty;

            var scriptToRun = Path.Combine(deployAgentData.DeployScriptRoot, deployAgentData.DeployScriptFile);

            if (!File.Exists(scriptToRun))
            {
                TraceHelper.TraceWarning(TraceSwitches.TfsDeployer, "BatchRunner - Could not find script: {0}", scriptToRun);
                output = string.Format("BatchRunner - Could not find script: {0}", scriptToRun);
            }
            else
            {
                var psi = new ProcessStartInfo(scriptToRun);
                psi.UseShellExecute        = false;
                psi.RedirectStandardOutput = true;
                psi.RedirectStandardInput  = true;
                psi.RedirectStandardError  = true;
                psi.WorkingDirectory       = deployAgentData.DeployScriptRoot;
                psi.Arguments = CreateArguments(deployAgentData);

                TraceHelper.TraceInformation(TraceSwitches.TfsDeployer, "BatchRunner - Executing Scripts: {0} with arguments {1} in working directory {2}", scriptToRun, psi.Arguments, psi.WorkingDirectory);

                // Start the process
                var proc = Process.Start(psi);
                if (proc == null)
                {
                    TraceHelper.TraceError(TraceSwitches.TfsDeployer, "Process.Start(...) returned null");
                }
                else
                {
                    using (var sOut = proc.StandardOutput)
                    {
                        proc.WaitForExit();
                        output = sOut.ReadToEnd().Trim();
                        TraceHelper.TraceInformation(TraceSwitches.TfsDeployer, "BatchRunner - Output From Command: {0}", output);
                    }

                    errorOccurred = false;
                }
            }

            var result = new DeployAgentResult
            {
                HasErrors = errorOccurred,
                Output    = output
            };

            return(result);
        }
        public DeployAgentResult Deploy(DeployAgentData deployAgentData)
        {
            var    variables = CreateVariables(deployAgentData);
            string command   = GeneratePipelineCommand(deployAgentData);

            ExecuteCommand(command, variables);

            var result = new DeployAgentResult
            {
                HasErrors = _errorOccurred,
                Output    = _output
            };

            return(result);
        }
Esempio n. 3
0
        public DeployAgentResult Deploy(DeployAgentData deployAgentData)
        {
            var request = new AgentRequest
            {
                NoProfile = true,
                Command   = PrepareImportGlobalVariablesScript(deployAgentData) + PrepareDeploymentScript(deployAgentData)
            };

            var runner = new PowerShellAgentRunner(request, deployAgentData.DeployScriptRoot, deployAgentData.Timeout, _clrVersion);

            if (_deploymentEventRecorder != null)
            {
                _deploymentEventRecorder.SetDeploymentOutputDelegate(deployAgentData.DeploymentId, () => runner.Output);
            }

            var exitCode = runner.Run();
            var result   = new DeployAgentResult {
                HasErrors = exitCode != 0, Output = runner.Output
            };

            return(result);
        }