Esempio n. 1
0
        static private void LaunchBuild(MogMainForm mainForm, string command, MOG_Ini options)
        {
            // Extract the Build's Options
            string BuildPlatform = "";
            string BuildType     = "";

            // Split up the Build's Options
            string [] commands = command.Trim().Split(" ".ToCharArray());
            if (command.Length == 0 || commands.Length < 1)
            {
                MOG_Prompt.PromptMessage("Request build", "Bad or missing command (" + command + ") in request build!", Environment.StackTrace);
                return;
            }

            BuildType = commands[0];

            if (commands.Length > 1)
            {
                BuildPlatform = commands[1];
            }


            // Get the list of available slaves to use for builds
            // Get the highest slaves
            string validSlaves = "";

            if (options.SectionExist("Builds.ValidSlaves") &&
                options.KeyExist("Builds.ValidSlaves", "Builds"))
            {
                validSlaves = options.GetString("Builds.ValidSlaves", "Builds");
            }

            string buildTypeSection = "Builds." + BuildType;

            // Locate the buildTool within the Build.Options.Info file
            string buildTool = "";

            // Determine what the executable name is
            if (options.SectionExist(buildTypeSection))
            {
                // Check for a buildTypeSection level validSlaves definition
                if (options.SectionExist("Builds.ValidSlaves") && options.KeyExist("Builds.ValidSlaves", buildTypeSection))
                {
                    validSlaves = options.GetString("Builds.ValidSlaves", buildTypeSection);
                }

                // Check if a specific BuildPlatform was specified? and
                // Check if we have keys in our buildTypeSection?
                if (BuildPlatform.Length > 0 &&
                    options.CountKeys(buildTypeSection) > 0)
                {
                    // Obtain the build tool for this build type and BuildPlatform
                    buildTool = options.GetString(buildTypeSection, BuildPlatform);
                    if (buildTool.Length > 0)
                    {
                        // Check for a BuildPlatform level validSlaves definition
                        if (options.SectionExist("Builds.ValidSlaves") && options.KeyExist("Builds.ValidSlaves", buildTypeSection + "." + BuildPlatform))
                        {
                            validSlaves = options.GetString("Builds.ValidSlaves", buildTypeSection + "." + BuildPlatform);
                        }
                    }
                }
                else if (options.KeyExist("Builds", BuildType))
                {
                    buildTool = options.GetString("Builds", BuildType);
                }
                else
                {
                }
            }

            // Make sure we have a valid build tool?
            if (buildTool.Length > 0)
            {
                // Locate the buildTool in the tools directories
                string buildToolRelativePath = Path.GetDirectoryName(buildTool);
                buildTool = MOG_ControllerSystem.LocateTool(buildToolRelativePath, buildTool);
                if (buildTool.Length > 0)
                {
                    //:: -----------------------------------------------------------------------
                    //:: MOG ENVIRONMENT VARIABLES
                    //:: -----------------------------------------------------------------------
                    string EnvVariables = MOG_EnvironmentVars.CreateToolsPathEnvironmentVariableString(buildToolRelativePath) + "," +
                                          MOG_EnvironmentVars.GetBuildProjectName() + "=" + MOG_ControllerProject.GetProjectName() + "," +
                                          MOG_EnvironmentVars.GetBuildProjectBranchName() + "=" + MOG_ControllerProject.GetBranchName() + "," +
                                          MOG_EnvironmentVars.GetBuildType() + "=" + BuildType + "," +
                                          MOG_EnvironmentVars.GetBuildPlatformName() + "=" + BuildPlatform + "," +
                                          MOG_EnvironmentVars.GetBuildTool() + "=" + buildTool + "," +
                                          MOG_EnvironmentVars.GetBuildToolPath() + "=" + System.IO.Path.GetDirectoryName(buildTool) + "," +
                                          MOG_EnvironmentVars.GetBuildRequestedBy() + "=" + MOG_ControllerProject.GetUser().GetUserName();

                    // Fire off the build
                    if (MOG_ControllerProject.Build(buildTool, validSlaves, MOG_ControllerProject.GetUser().GetUserName(), EnvVariables))
                    {
                        string message = "Build Request Successfull.\n" +
                                         "You will be notified when it is completed.";
                        MessageBox.Show(message, "Refresh Build", MessageBoxButtons.OK);
                    }
                }
                else
                {
                    string message = "MOG was unable to locate the specified build tool.\n" +
                                     "BUILD TOOL: " + buildTool + "\n\n" +
                                     "Your MOG Administrator may need to internalize this tool before it will work.";
                    MOG_Prompt.PromptMessage("Request Build", message);
                }
            }
            else
            {
                string message = "No build tool was located for the selected build type.\n" +
                                 "BUILD TYPE: " + buildTypeSection + "\n\n" +
                                 "Your MOG Administrator may need to edit the 'Build.Options.Info' file to configure this build type.";
                MOG_Prompt.PromptMessage("Request Build", message);
            }
        }