Exemplo n.º 1
0
        void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            CheckBuildMachineAliveStatus();

            // Check SVN server every 60 seconds for a new HEAD revision.
            if (_iLastSVNCheckTimestamp + iSVNRevisionCheckInterval < LinuxDateTime.Now())
            {
                CheckForNewRevision();
            }

            lock (_Lock)
            {
                if (IsHibernationPossible())
                {
                    // Conditions for hibernation are met - increase hibernation timer
                    _iHibernationTime += iTimerInterval;
                    if (_iHibernationTime > iHibernationDelay)
                    {
                        _iHibernationTime = 0;
                        // We have been idle for 15min (iHibernationDelay), thus we now go into hibernation.
                        ezProcessHelper.RunExternalExe("shutdown", "-h", _Settings.AbsOutputFolder, null);
                    }
                }
                else
                {
                    // Reset hibernation timer
                    _iHibernationTime = 0;
                }
            }
        }
Exemplo n.º 2
0
        bool CheckForNewRevision()
        {
            _iLastSVNCheckTimestamp = LinuxDateTime.Now();

            // Call 'svn info' on the server and extract the HEAD revision from the stdout stream.
            const string sRevisionToken = "Revision: ";
            string       sArguments     = string.Format("info -r HEAD {0} --username {1} --password {2} --non-interactive --trust-server-cert",
                                                        _Settings.SVNServer, _Settings.SVNUsername, _Settings.SVNPassword);

            ezProcessHelper.ProcessResult ProcessRes = ezProcessHelper.RunExternalExe("svn", sArguments, _Settings.AbsOutputFolder, null, 20 * 1000);
            if (ProcessRes.ExitCode != 0)
            {
                return(false);
            }

            string[] lines = ProcessRes.StdOut.Split('\n');
            foreach (string line in lines)
            {
                if (line.StartsWith(sRevisionToken))
                {
                    string sValue = line.Substring(sRevisionToken.Length);
                    try
                    {
                        int iRev = Convert.ToInt32(sValue);
                        if (iRev != _HeadRevision)
                        {
                            lock (_Lock)
                            {
                                _HeadRevision = iRev;
                                Console.WriteLine("HEAD revision: {0}", _HeadRevision);
                            }
                        }
                    }
                    catch (FormatException)
                    {
                        Console.WriteLine("'CheckForNewRevision' failed to extract revision number from line: '{0}", line);
                        return(false);
                    }
                    return(true);
                }
            }

            lock (_Lock)
            {
                Console.WriteLine("'CheckForNewRevision' failed to find the revision line in the svn: '{0}{1}", ProcessRes.StdOut, ProcessRes.ErrorOut);
                _HeadRevision = -1;
            }
            return(false);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Runs the build process for the given SVN revision.
        /// </summary>
        /// <param name="iRevision">The SVN revision to which should be updated before building.</param>
        /// <param name="bClean">Whether the builds should be cleaned instead of incremental compiles.</param>
        /// <returns>If false is returned, SVN update failed and the build machine is now in fatal error state
        /// and should not accept any more requests until an admin fixed the issue.</returns>
        public bool Run(int iRevision, bool bClean)
        {
            _Result.Clean();
            _Result.Settings.Revision = iRevision;

            Console.WriteLine("**** Starting building rev {0} of build {1} ****", iRevision, _Result.Settings.Configuration);
            Stopwatch sw = new Stopwatch();

            sw.Start();

            ///
            if (!String.IsNullOrEmpty(_Result.Settings.PreBuildStep))
            {
                ezProcessHelper.RunExternalExe(_Result.Settings.PreBuildStep, "", _Result.Settings.AbsCMakeWorkspace, null);
            }
            ///
            _Result.SVNResult   = _SVN.Run(iRevision);
            _Result.CMakeResult = _CMake.Run(_Result.SVNResult);
            _Result.BuildResult = _Build.Run(_Result.CMakeResult, bClean);
            _Result.TestResult  = _Test.Run(_Result.CMakeResult, _Result.BuildResult);

            sw.Stop();
            _Result.Duration = sw.Elapsed.TotalSeconds;
            _Result.Success  = _Result.SVNResult.Success && _Result.CMakeResult.Success &&
                               _Result.BuildResult.Success && _Result.TestResult.Success;
            _Result.Settings.Timestamp = LinuxDateTime.Now();
            if (!WriteResultToFile())
            {
                Console.WriteLine("Writing result to file failed!");
            }

            Console.WriteLine("**** Building ended ****");
            // Returns whether the process of building was run properly, not whether everything succeeded or not.
            // If SVN fails somehow we cannot continue and the build machine is set into fatal failure mode.
            return(_Result.SVNResult.Success);
        }