Ejemplo n.º 1
0
        private void VerifyDocumentHasValidRootElement(XmlDocument configXml, IConfigurationErrorProcesser errorProcesser)
        {
            var version = Assembly.GetExecutingAssembly().GetName().Version;

            if (configXml.DocumentElement == null || configXml.DocumentElement.Name != ROOT_ELEMENT)
            {
                throw new ConfigurationException("The configuration document has an invalid root element.  Expected <cruisecontrol>.");
            }
            else if (string.IsNullOrEmpty(configXml.DocumentElement.NamespaceURI))
            {
                // Tell the user there is no version information
                errorProcesser.ProcessWarning("Configuration does not have any version information - assuming the configuration is for version " + version.ToString(2));
            }
            else
            {
                // The last two items are the version number
                var parts         = configXml.DocumentElement.NamespaceURI.Split('/');
                var versionNumber = parts[parts.Length - 2] + "." + parts[parts.Length - 1];
                if (version.ToString(2) != versionNumber)
                {
                    // Tell the user the version does not match
                    errorProcesser.ProcessWarning(
                        "Version mismatch - CruiseControl.NET is version " + version.ToString(2) +
                        ", the configuration is for version " + versionNumber);
                }
            }
        }
Ejemplo n.º 2
0
 public void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
 {
     if (this.RepeatCount <= 0)
     {
         errorProcesser.ProcessWarning("count is less than 1!");
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Validates this task.
        /// </summary>
        /// <param name="configuration"></param>
        /// <param name="parent"></param>
        /// <param name="errorProcesser"></param>
        public override void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            base.Validate(configuration, parent, errorProcesser);
            var project = parent.GetAncestorValue <Project>();

            if (project != null)
            {
                // Check if this task is set in the publishers section
                var isPublisher = false;
                foreach (var publisher in project.Publishers)
                {
                    if (object.ReferenceEquals(publisher, this))
                    {
                        isPublisher = true;
                        break;
                    }
                }

                // Display a warning
                if (isPublisher)
                {
                    errorProcesser.ProcessWarning("Putting the parallel task in the publishers section may cause unpredictable results");
                }
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Checks the internal validation of the item.
 /// </summary>
 /// <param name="configuration">The entire configuration.</param>
 /// <param name="parent">The parent item for the item being validated.</param>
 /// <param name="errorProcesser">The error processer to use.</param>
 public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
 {
     if ((this.Actions == null) || (this.Actions.Length == 0))
     {
         errorProcesser.ProcessWarning("This task will not do anything - no actions specified");
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Checks the internal validation of the item.
        /// </summary>
        /// <param name="configuration">The entire configuration.</param>
        /// <param name="parent">The parent item for the item being validated.</param>
        /// <param name="errorProcesser">The error processer to use.</param>
        public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            var parentProject = parent.GetAncestorValue <Project>();

            if (parentProject != null)
            {
                // Attempt to find this publisher in the publishers section
                var isPublisher = false;
                foreach (var task in parentProject.Publishers)
                {
                    if (task == this)
                    {
                        isPublisher = true;
                        break;
                    }
                }

                // If not found then throw a validation exception
                if (!isPublisher)
                {
                    errorProcesser.ProcessWarning(
                        "Email publishers are best placed in the publishers section of the configuration");
                }
            }
            else
            {
                errorProcesser.ProcessError(new CruiseControlException("This publisher can only belong to a project"));
            }

            // Make sure the xslFiles are not empty
            if (this.xslFiles != null && this.XslFiles.Any(f => string.IsNullOrEmpty(f)))
            {
                errorProcesser.ProcessError("xslFiles cannot contain empty or null filenames");
            }
        }
 public void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
 {
     if (this.RepeatCount <= 0)
     {
         errorProcesser.ProcessWarning("count is less than 1!");
     }
 }
 /// <summary>
 /// Checks the internal validation of the item.
 /// </summary>
 /// <param name="configuration">The entire configuration.</param>
 /// <param name="parent">The parent item for the item being validated.</param>
 /// <param name="errorProcesser">The error processer to use.</param>
 public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
 {
     if ((this.Actions == null) || (this.Actions.Length == 0))
     {
         errorProcesser.ProcessWarning("This task will not do anything - no actions specified");
     }
 }
        /// <summary>
        /// Checks the internal validation of the item.
        /// </summary>
        /// <param name="configuration">The entire configuration.</param>
        /// <param name="parent">The parent item for the item being validated.</param>
        /// <param name="errorProcesser">The error processer to use.</param>
        public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            // Get the name of the executable
            var canCheck = true;
            var fileName = this.GetProcessFilename().Trim();

            if (!Path.IsPathRooted(fileName))
            {
                var project = parent.GetAncestorValue <Project>();
                if (project != null)
                {
                    var result    = ConfigurationValidationUtils.GenerateResultForProject(project);
                    var directory = this.GetProcessBaseDirectory(result);
                    fileName = Path.Combine(directory, fileName);
                }
                else
                {
                    // Can't generate the path, therefore can't check for the file
                    canCheck = false;
                }
            }

            // See if it exists - shortcut the process if there is an exact match (the remainder uses pattern matching to try and find the file)
            if (canCheck && !this.IOSystemActual.FileExists(fileName))
            {
                var fileExists = false;

                // This needs to be from the filename, just in case the path is a relative path and it has been joined to the base directory
                var directory = Path.GetDirectoryName(fileName);
                if (this.IOSystemActual.DirectoryExists(directory))
                {
                    // Get all the files and check each file
                    var files           = this.IOSystemActual.GetFilesInDirectory(directory);
                    var executableName1 = Path.GetFileNameWithoutExtension(fileName);
                    var executableName2 = Path.GetFileName(fileName);
                    foreach (var file in files)
                    {
                        // Strip the extension so we can compare partial file names (since Windows does not need the .exe extension)
                        var fileToTest = Path.GetFileNameWithoutExtension(file);

                        // Need to perform two checks here as some Windows names have two multiple dots - therefore GetFileNameWithoutExtension will strip the last part,
                        // whether or not it is an extension
                        if (string.Equals(fileToTest, executableName1, StringComparison.InvariantCultureIgnoreCase) ||
                            string.Equals(fileToTest, executableName2, StringComparison.InvariantCultureIgnoreCase))
                        {
                            fileExists = true;
                            break;
                        }
                    }
                }

                if (!fileExists)
                {
                    errorProcesser.ProcessWarning("Unable to find executable '" + fileName + "'");
                }
            }
        }
 public void Validate(IConfiguration configuration,
                      ConfigurationTrace parent,
                      IConfigurationErrorProcesser errorProcesser)
 {
     if (string.IsNullOrEmpty(this.MonitorFile))
     {
         errorProcesser.ProcessError("File cannot be empty");
     }
     else if (!File.Exists(this.MonitorFile))
     {
         errorProcesser.ProcessWarning(
             "File '" + this.MonitorFile + "' does not exist");
     }
 }
Ejemplo n.º 10
0
 public void Validate(IConfiguration configuration,
     ConfigurationTrace parent,
     IConfigurationErrorProcesser errorProcesser)
 {
     if (string.IsNullOrEmpty(this.MonitorFile))
     {
         errorProcesser.ProcessError("File cannot be empty");
     }
     else if (!File.Exists(this.MonitorFile))
     {
         errorProcesser.ProcessWarning(
             "File '" + this.MonitorFile + "' does not exist");
     }
 }
 public void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
 {
     if (!string.IsNullOrWhiteSpace(this.LogFile))
     {
         try
         {
             string dir = Path.GetDirectoryName(this.LogFile);
             if (!Directory.Exists(dir))
             {
                 Directory.CreateDirectory(dir);
             }
             Log("Validating permissions");
         }
         catch (Exception ex)
         {
             errorProcesser.ProcessWarning("Could not create log file: ", ex.ToString());
             this.LogFile = null;
         }
     }
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Checks the internal validation of the item.
        /// </summary>
        /// <param name="configuration">The entire configuration.</param>
        /// <param name="parent">The parent item for the item being validated.</param>
        /// <param name="errorProcesser">The error processer to use.</param>
        public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            var parentProject = parent.GetAncestorValue<Project>();
            if (parentProject != null)
            {
                // Attempt to find this publisher in the publishers section
                var isPublisher = false;
                foreach (var task in parentProject.Publishers)
                {
                    if (task == this)
                    {
                        isPublisher = true;
                        break;
                    }
                }

                // If not found then throw a validation exception
                if (!isPublisher)
                {
                    errorProcesser.ProcessWarning("Email publishers are best placed in the publishers section of the configuration");
                }
            }
            else
            {
                errorProcesser.ProcessError(
                    new CruiseControlException("This publisher can only belong to a project"));
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Validates this task.
        /// </summary>
        /// <param name="configuration"></param>
        /// <param name="parent"></param>
        /// <param name="errorProcesser"></param>
        public override void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            base.Validate(configuration, parent, errorProcesser);
            var project = parent.GetAncestorValue<Project>();

            if (project != null)
            {
                // Check if this task is set in the publishers section
                var isPublisher = false;
                foreach (var publisher in project.Publishers)
                {
                    if (object.ReferenceEquals(publisher, this))
                    {
                        isPublisher = true;
                        break;
                    }
                }

                // Display a warning
                if (isPublisher)
                {
                    errorProcesser.ProcessWarning("Putting the parallel task in the publishers section may cause unpredictable results");
                }
            }
        }
        /// <summary>
        /// Checks the internal validation of the item.
        /// </summary>
        /// <param name="configuration">The entire configuration.</param>
        /// <param name="parent">The parent item for the item being validated.</param>
        /// <param name="errorProcesser">The error processer to use.</param>
        public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            // Get the name of the executable
            var canCheck = true;
            var fileName = this.GetProcessFilename().Trim();
            if (!Path.IsPathRooted(fileName))
            {
                var project = parent.GetAncestorValue<Project>();
                if (project != null)
                {
                    var result = ConfigurationValidationUtils.GenerateResultForProject(project);
                    var directory = this.GetProcessBaseDirectory(result);
                    fileName = Path.Combine(directory, fileName);
                }
                else
                {
                    // Can't generate the path, therefore can't check for the file
                    canCheck = false;
                }
            }

            // See if it exists - shortcut the process if there is an exact match (the remainder uses pattern matching to try and find the file)
            if (canCheck && !this.IOSystemActual.FileExists(fileName))
            {
                var fileExists = false;

                // This needs to be from the filename, just in case the path is a relative path and it has been joined to the base directory
                var directory = Path.GetDirectoryName(fileName);
                if (this.IOSystemActual.DirectoryExists(directory))
                {
                    // Get all the files and check each file
                    var files = this.IOSystemActual.GetFilesInDirectory(directory);
                    var executableName1 = Path.GetFileNameWithoutExtension(fileName);
                    var executableName2 = Path.GetFileName(fileName);
                    foreach (var file in files)
                    {
                        // Strip the extension so we can compare partial file names (since Windows does not need the .exe extension)
                        var fileToTest = Path.GetFileNameWithoutExtension(file);

                        // Need to perform two checks here as some Windows names have two multiple dots - therefore GetFileNameWithoutExtension will strip the last part, 
                        // whether or not it is an extension
                        if (string.Equals(fileToTest, executableName1, StringComparison.OrdinalIgnoreCase) ||
                            string.Equals(fileToTest, executableName2, StringComparison.OrdinalIgnoreCase))
                        {
                            fileExists = true;
                            break;
                        }
                    }
                }

                if (!fileExists)
                {
                    errorProcesser.ProcessWarning("Unable to find executable '" + fileName + "'");
                }
            }
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Validate the project details.
 /// </summary>
 /// <remarks>
 /// Currently the only check is the project name does not contain any invalid characters.
 /// </remarks>
 private void ValidateProject(IConfigurationErrorProcesser errorProcesser)
 {
     if (ContainsInvalidChars(this.Name))
     {
         errorProcesser.ProcessWarning(
             string.Format(System.Globalization.CultureInfo.CurrentCulture, "Project name '{0}' contains some chars that could cause problems, better use only numbers and letters",
                 Name));
     }
 }
 private void VerifyDocumentHasValidRootElement(XmlDocument configXml, IConfigurationErrorProcesser errorProcesser)
 {
     var version = Assembly.GetExecutingAssembly().GetName().Version;
     if (configXml.DocumentElement == null || configXml.DocumentElement.Name != ROOT_ELEMENT)
     {
         throw new ConfigurationException("The configuration document has an invalid root element.  Expected <cruisecontrol>.");
     }
     else if (string.IsNullOrEmpty(configXml.DocumentElement.NamespaceURI))
     {
         // Tell the user there is no version information
         errorProcesser.ProcessWarning("Configuration does not have any version information - assuming the configuration is for version " + version.ToString(2));
     }
     else
     {
         // The last two items are the version number
         var parts = configXml.DocumentElement.NamespaceURI.Split('/');
         var versionNumber = parts[parts.Length - 2] + "." + parts[parts.Length - 1];
         if (version.ToString(2) != versionNumber)
         {
             // Tell the user the version does not match
             errorProcesser.ProcessWarning(
                 "Version mismatch - CruiseControl.NET is version " + version.ToString(2) +
                 ", the configuration is for version " + versionNumber);
         }
     }
 }
Ejemplo n.º 17
0
        /// <summary>
        /// Checks the internal validation of the item.
        /// </summary>
        /// <param name="configuration">The entire configuration.</param>
        /// <param name="parent">The parent item for the item being validated.</param>
        /// <param name="errorProcesser">The error processer to use.</param>
        public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser)
        {
            var parentProject = parent.GetAncestorValue<Project>();
            if (parentProject != null)
            {
                // Attempt to find this publisher in the publishers section
                var isPublisher = false;
                foreach (var task in parentProject.Publishers)
                {
                    if (task == this)
                    {
                        isPublisher = true;
                        break;
                    }
                }

                // If not found then throw a validation exception
                if (!isPublisher)
                {
                    errorProcesser.ProcessWarning(
                        "Email publishers are best placed in the publishers section of the configuration");
                }
            }
            else
            {
                errorProcesser.ProcessError(new CruiseControlException("This publisher can only belong to a project"));
            }

            // Make sure the xslFiles are not empty
            if (this.xslFiles != null &&  this.XslFiles.Any(f => string.IsNullOrEmpty(f)))
            {
                errorProcesser.ProcessError("xslFiles cannot contain empty or null filenames");
            }
        }