예제 #1
0
        // zhiyuan.peng:
        // add a new reference
        public void AddReference(string target)
        {
            XmlElement e = Xml.CreateElement("reference");

            e.SetAttribute("target", target);
            Xml.DocumentElement.AppendChild(e);
        }
예제 #2
0
        public BuildConfigXmlGenerator(IBuildConfigXmlClient buildConfigXmlClient = null, bool buildNonStubVersion = false)
        {
            _buildConfigXmlClient = buildConfigXmlClient;

            if (buildNonStubVersion)
            {
                BuildConfigXml = new BuildConfigXml(_buildConfigXmlClient, Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
            }
            else
            {
                BuildConfigXml = Substitute.For <BuildConfigXml>(_buildConfigXmlClient, Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
            }

            Xml.AppendChild(Xml.CreateXmlDeclaration("1.0", "UTF-8", null));

            BuildTypeElement = (XmlElement)Xml.AppendChild(Xml.CreateElement("build-type"));
            BuildTypeElement.SetAttribute("uuid", Guid.NewGuid().ToString());

            NameElement = (XmlElement)BuildTypeElement.AppendChild(Xml.CreateElement("name"));

            SettingsElement = (XmlElement)BuildTypeElement.AppendChild(Xml.CreateElement("settings"));
            SettingsElement.SetAttribute("ref", "CPlusPlusTemplate_v1");

            ParametersElement = (XmlElement)SettingsElement.AppendChild(Xml.CreateElement("parameters"));
        }
예제 #3
0
        private XmlElement CreateSecurity()
        {
            var headerXml   = GetHeader();
            var securityXml = Xml.CreateElement("wsse", "Security", Soap.Namespaces.WebServiceSecurityExtensions);

            headerXml.AppendChild(securityXml);
            return(securityXml);
        }
예제 #4
0
        public BuildConfigXmlGenerator WithParameter(string name, string value)
        {
            var paramElement = (XmlElement)ParametersElement.AppendChild(Xml.CreateElement("param"));

            paramElement.SetAttribute("name", name);
            paramElement.SetAttribute("value", value);

            return(this);
        }
예제 #5
0
        static XmlNode NodeWithValue(string nodeName, string value)
        {
            XmlNode node = Xml.CreateElement(nodeName);

            XmlNode inner = Xml.CreateTextNode(value);

            node.AppendChild(inner);

            return(node);
        }
예제 #6
0
        static XmlNode NodeWithAttribute(string nodeName, string attrName, string attrValue)
        {
            XmlNode node = Xml.CreateElement(nodeName);

            XmlAttribute attr = Xml.CreateAttribute(attrName);

            attr.Value = attrValue;
            node.Attributes.Append(attr);

            return(node);
        }
예제 #7
0
        static XmlNode NodeWithAttributeValue(string nodeName, string value, string attrName, string attrValue)
        {
            XmlNode node = Xml.CreateElement(nodeName);

            XmlAttribute attr = Xml.CreateAttribute(attrName);

            attr.Value = attrValue;
            node.Attributes.Append(attr);

            XmlNode inner = Xml.CreateTextNode(value);

            node.AppendChild(inner);

            return(node);
        }
예제 #8
0
        public virtual void CreateArtifactDependency(CreateArtifactDependency dependency)
        {
            Log.Debug($"XML CreateArtifactDependency for: {BuildConfigId}, to: {dependency.DependencyBuildConfigId}");

            var dependencyElement = (XmlElement)ArtifactDependenciesElement.AppendChild(Xml.CreateElement("dependency"));

            dependencyElement.SetAttribute("sourceBuildTypeId", dependency.DependencyBuildConfigId);
            dependencyElement.SetAttribute("cleanDestination", dependency.CleanDestinationDirectory.ToString().ToLower());

            var revisionRuleElement = (XmlElement)dependencyElement.AppendChild(Xml.CreateElement("revisionRule"));

            revisionRuleElement.SetAttribute("name", dependency.RevisionName);
            revisionRuleElement.SetAttribute("revision", dependency.RevisionValue);

            var artifactElement = (XmlElement)dependencyElement.AppendChild(Xml.CreateElement("artifact"));

            artifactElement.SetAttribute("sourcePath", dependency.PathRules);

            _buildConfigXmlClient.Commit(this, $"TCC {BuildConfigId} Create Artifact Dependency to {dependency.DependencyBuildConfigId}");
        }
예제 #9
0
        public virtual void CreateSnapshotDependency(CreateSnapshotDependency dependency)
        {
            Log.Debug($"XML CreateSnapshotDependency for: {dependency.TargetBuildConfigId}, to: {dependency.DependencyBuildConfigId}");

            var dependOnElement = (XmlElement)DependenciesElement.AppendChild(Xml.CreateElement("depend-on"));

            dependOnElement.SetAttribute("sourceBuildTypeId", dependency.DependencyBuildConfigId);

            var optionsElement = (XmlElement)dependOnElement.AppendChild(Xml.CreateElement("options"));

            var option1Element = (XmlElement)optionsElement.AppendChild(Xml.CreateElement("option"));

            option1Element.SetAttribute("name", "take-started-build-with-same-revisions");
            option1Element.SetAttribute("value", dependency.TakeStartedBuildWithSameRevisions.ToString().ToLower());

            var option2Element = (XmlElement)optionsElement.AppendChild(Xml.CreateElement("option"));

            option2Element.SetAttribute("name", "take-successful-builds-only");
            option2Element.SetAttribute("value", dependency.TakeSuccessFulBuildsOnly.ToString().ToLower());

            _buildConfigXmlClient.Commit(this, $"TCC {BuildConfigId} Create Snapshot Dependency to {dependency.DependencyBuildConfigId}");
        }
예제 #10
0
        public virtual void SetParameterValue(string name, string value)
        {
            Log.Trace($"XML SetParameterValue for: {BuildConfigId}, {name}: {value}");
            var paramElement = (XmlElement)Xml.SelectSingleNode("/build-type/settings/parameters/param[@name='" + name + "']");

            if (paramElement == null)
            {
                if (ParametersElement == null)
                {
                    SettingsElement.AppendChild(Xml.CreateElement("parameters"));
                }
                var newParamElement = (XmlElement)ParametersElement.AppendChild(Xml.CreateElement("param"));
                newParamElement.SetAttribute("name", name);
                newParamElement.SetAttribute("value", value);
            }
            else
            {
                paramElement.SetAttribute("value", value);
            }

            _buildConfigXmlClient.Commit(this, $"TCC {BuildConfigId} Set Parameter {name} = {value}");
        }
예제 #11
0
 public XmlElement CreateElement(string name)
 {
     return(Xml.CreateElement(name));
 }
예제 #12
0
 public BuildConfigXmlGenerator WithTemplateId(string templateId)
 {
     SettingsElement = (XmlElement)BuildTypeElement.AppendChild(Xml.CreateElement("settings"));
     SettingsElement.SetAttribute("ref", templateId);
     return(this);
 }