Team City を使用して、Windows 用のパペットを使用して Windows 2008 R2 マシンをプロビジョニングしようとしています。リモートで接続し、ターゲット サーバー内の puppet クライアントを呼び出す TC Agent があります。Powershell を使用しようとしましたが、管理者として puppet を実行しようとすると問題が発生したため、出力をリダイレクトする C# コード ユーティリティを作成しましたが、TC では機能していないようですが、ローカルでは機能します。
namespace RunAsAdmin
{
class Program
{
static void Main(string[] args)
{
Process proc = new Process();
Process p = new Process();
p.StartInfo.FileName = @"psexec.exe";
p.StartInfo.Arguments = "/accepteula \\\\" + args[0] + " -s \"C:\\Program Files (x86)\\Puppet Labs\\Puppet\\bin\\puppet.bat\" agent --test --no-daemonize --verbose --logdest console ";
p.StartInfo.Verb = "runas";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
p.Start();
while (p.HasExited == false) {
Console.WriteLine(p.StandardOutput.ReadLine());
}
Console.ReadLine();
p.WaitForExit();
p.Close();
}
}
}
コードはローカルでも TC でも完全に機能し、管理者として実行しても問題はありませんが、TC でビルド出力が表示されません。