Example #1
0
        public override bool Equals(object obj)
        {
            // If parameter is null return false.
            if (obj == null)
            {
                return(false);
            }

            // If parameter cannot be cast to Build return false.
            BuildConfig bc = obj as BuildConfig;

            if (bc == null)
            {
                return(false);
            }

            // Return true if the fields match:
            return(Id == bc.Id);
        }
Example #2
0
        /// <summary>
        /// Ensure that cloned Build Config uses template used by current version of Build Config
        /// Because old templates might use VCS root, which is not available anymore
        /// </summary>
        /// <param name="currentBuildConfig">Latest version of the build configuration</param>
        public virtual void SwitchTemplateAndRepoToCurrentState(BuildConfig currentBuildConfig)
        {
            var settingsElement = (XmlElement)Xml.SelectSingleNode("/build-type/settings");

            var refAttribute = settingsElement.Attributes["ref"];

            if (refAttribute == null)
            {
                Log.Debug("Build Configuration is not attached to any template. Skipping template switching step.");
                return;
            }

            if (currentBuildConfig.Templates.Count > 1)
            {
                throw new NotSupportedException("Currently we don't use multiple templates. If we will ever will then will need to implement this feature");
            }

            if (currentBuildConfig.Templates.Count == 0)
            {
                Log.Debug("Current version of the Build Configuration is not attached to any template. Skipping template switching step.");
                return;
            }

            var oldTemplateId = refAttribute.Value;

            var newTemplateId = currentBuildConfig.Templates.BuildType.First().Id;

            if (oldTemplateId != newTemplateId)
            {
                Log.Warn($"XML Switch template on {BuildConfigId} from {oldTemplateId} to {newTemplateId}");

                settingsElement.SetAttribute("ref", newTemplateId);
                _buildConfigXmlClient.Commit(this, $"TCC {BuildConfigId} Switch template from {oldTemplateId} to {newTemplateId}");

                var currentGitRepoPathParameter = currentBuildConfig.Parameters[ParameterName.GitRepoPath];
                if (currentGitRepoPathParameter != null)
                {
                    SetParameterValue(ParameterName.GitRepoPath, currentBuildConfig.Parameters[ParameterName.GitRepoPath].Value);
                }
            }
        }