Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
3.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 2000
  5. //
  6. // File: bcbuild.js
  7. //
  8. // Contents: A script which will connect to a Build Manager machine and
  9. // initiate a file publishing phase.
  10. //
  11. //
  12. //----------------------------------------------------------------------------
  13. // Arguments: The name and identity of a machine to connect to.
  14. var g_vRet;
  15. var g_strMachine;
  16. var g_strIdentity;
  17. var g_objShell = WScript.CreateObject( "WScript.Shell" );
  18. var g_objWshEnv = g_objShell.Environment("Process");
  19. g_strIdentity = g_objWshEnv.Item("__MTSCRIPT_ENV_IDENTITY");
  20. if (!g_strIdentity || g_strIdentity == '')
  21. {
  22. WScript.Echo("Error: Missing env var '__MTSCRIPT_ENV_IDENTITY'");
  23. WScript.Quit(1);
  24. }
  25. if (WScript.Arguments.length > 0)
  26. {
  27. if (WScript.Arguments.length < 2)
  28. {
  29. WScript.Echo("Error: You cannot specify just machine name - identity required");
  30. WScript.Quit(1);
  31. }
  32. g_strMachine = WScript.Arguments(0);
  33. g_strIdentity = WScript.Arguments(1);
  34. }
  35. g_vRet = PublishFilesNow(g_strMachine, g_strIdentity);
  36. WScript.Quit(g_vRet != true); // return 0 on success
  37. function PublishFilesNow(strMachine, strIdentity)
  38. {
  39. var objRemote;
  40. var objEnviron;
  41. objRemote = new ActiveXObject('MTScript.Proxy');
  42. objRemote.ConnectToMTScript(strMachine, strIdentity, false);
  43. if (objRemote.PublicData.strMode == 'idle')
  44. {
  45. WScript.Echo("the machine is idle");
  46. return false;
  47. }
  48. if (objRemote.PublicData.strMode == 'slave')
  49. {
  50. objEnviron = objRemote.Exec('getpublic', 'PrivateData.objEnviron');
  51. objEnviron = eval(objEnviron);
  52. if (objEnviron.BuildManager && objEnviron.BuildManager.Name)
  53. {
  54. WScript.Echo("The build manager is " + objEnviron.BuildManager.Name + "\\" + objEnviron.BuildManager.Identity);
  55. return PublishFilesNow(objEnviron.BuildManager.Name, objEnviron.BuildManager.Identity);
  56. }
  57. WScript.Echo("could not determine the build manager");
  58. }
  59. g_vRet = objRemote.Exec('publishfilesnow','');
  60. if (g_vRet == 'busy')
  61. {
  62. WScript.Echo("cannot publish files now: build is in progress");
  63. return true;
  64. }
  65. g_vRet = eval(g_vRet);
  66. PrintPublishedFiles(g_vRet);
  67. return true;
  68. }
  69. function PrintPublishedFiles(objPublishedFiles)
  70. {
  71. var objFiles;
  72. var nIndex;
  73. var nEnlistment;
  74. var strFile;
  75. for(nIndex in objPublishedFiles)
  76. {
  77. for(nEnlistment in objPublishedFiles[nIndex])
  78. {
  79. objFiles = objPublishedFiles[nIndex][nEnlistment];
  80. if (objFiles.aNames != null && objFiles.aNames.length > 0)
  81. {
  82. WScript.Echo("Files published by " + objFiles.strLocalMachine);
  83. for(strFile in objFiles.aNames)
  84. {
  85. WScript.Echo(" " + objFiles.aNames[strFile].strName);
  86. }
  87. }
  88. }
  89. }
  90. }