예제 #1
0
        public void Should_create_artifact_dependency(
            IBuildConfigXmlClient buildConfigXmlClient,
            string dependencyBuildConfigId,
            bool cleanDestination,
            string revisionName,
            string revisionValue,
            string pathRules)
        {
            var buildConfigXml = new BuildConfigXmlGenerator(buildConfigXmlClient, buildNonStubVersion: true).Create();

            var dependencyToCreate = new CreateArtifactDependency(Arg.Any <string>(), dependencyBuildConfigId);

            dependencyToCreate.CleanDestinationDirectory = cleanDestination;
            dependencyToCreate.RevisionName  = revisionName;
            dependencyToCreate.RevisionValue = revisionValue;
            dependencyToCreate.PathRules     = pathRules;

            buildConfigXml.CreateArtifactDependency(dependencyToCreate);

            var dependencyElement = (XmlElement)buildConfigXml.Xml.SelectSingleNode("/build-type/settings/artifact-dependencies/dependency[@sourceBuildTypeId='" + dependencyBuildConfigId + "']");

            Assert.Equal(dependencyBuildConfigId, dependencyElement?.Attributes["sourceBuildTypeId"].Value);
            Assert.Equal(cleanDestination.ToString().ToLower(), dependencyElement?.Attributes["cleanDestination"].Value);

            var revisionRuleElement = dependencyElement?.SelectSingleNode("revisionRule");

            Assert.Equal(revisionName, revisionRuleElement?.Attributes?["name"].Value);
            Assert.Equal(revisionValue, revisionRuleElement?.Attributes?["revision"].Value);

            var artifactElement = dependencyElement?.SelectSingleNode("artifact");

            Assert.Equal(pathRules, artifactElement?.Attributes?["sourcePath"].Value);
        }
예제 #2
0
        public BuildConfigXmlGenerator WithDependencies(DependencyDefinition[] dependencyDefinitions)
        {
            foreach (var dependencyDefinition in dependencyDefinitions)
            {
                var createArtifactDependency = new CreateArtifactDependency(BuildConfigXml.BuildConfigId, dependencyDefinition.SourceBuildConfig.Id);

                BuildConfigXml.CreateArtifactDependency(createArtifactDependency);
            }

            return(this);
        }
예제 #3
0
        public void Should_freeze_all_artifact_dependencies(
            IBuildConfigXmlClient buildConfigXmlClient,
            string dependencyBuildConfigId,
            CreateArtifactDependency artifactDependency,
            Build asOfBuild)
        {
            artifactDependency.DependencyBuildConfigId    = dependencyBuildConfigId;
            asOfBuild.ArtifactDependencies[0].BuildTypeId = dependencyBuildConfigId;

            var buildConfigXml = new BuildConfigXmlGenerator(buildConfigXmlClient, buildNonStubVersion: true)
                                 .WithArtifactDependency(artifactDependency)
                                 .Create();

            buildConfigXml.FreezeAllArtifactDependencies(asOfBuild);

            var dependencyElement   = (XmlElement)buildConfigXml.Xml.SelectSingleNode("/build-type/settings/artifact-dependencies/dependency[@sourceBuildTypeId='" + dependencyBuildConfigId + "']");
            var revisionRuleElement = (XmlElement)dependencyElement?.SelectSingleNode("revisionRule");

            Assert.Equal("buildNumber", revisionRuleElement?.Attributes["name"].Value);
            Assert.Equal(asOfBuild.ArtifactDependencies[0].Number, revisionRuleElement?.Attributes["revision"].Value);
        }
예제 #4
0
        public void Should_update_artifact_dependency(
            IBuildConfigXmlClient buildConfigXmlClient,
            string dependencyBuildConfigId,
            CreateArtifactDependency before,
            string newSourceBuildConfigId,
            string newRevisionName,
            string newRevisionValue)
        {
            before.DependencyBuildConfigId = dependencyBuildConfigId;

            var buildConfigXml = new BuildConfigXmlGenerator(buildConfigXmlClient, buildNonStubVersion: true)
                                 .WithArtifactDependency(before)
                                 .Create();

            buildConfigXml.UpdateArtifactDependency(dependencyBuildConfigId, newSourceBuildConfigId, newRevisionName, newRevisionValue);

            var dependencyElement   = (XmlElement)buildConfigXml.Xml.SelectSingleNode("/build-type/settings/artifact-dependencies/dependency[@sourceBuildTypeId='" + newSourceBuildConfigId + "']");
            var revisionRuleElement = (XmlElement)dependencyElement?.SelectSingleNode("revisionRule");

            Assert.Equal(newRevisionName, revisionRuleElement?.Attributes["name"].Value);
            Assert.Equal(newRevisionValue, revisionRuleElement?.Attributes["revision"].Value);
        }
예제 #5
0
        public async Task CreateArtifactDependency(CreateArtifactDependency dependency)
        {
            Log.DebugFormat("API BuildConfig.CreateArtifactDependency for: {0}, to: {1}", dependency.TargetBuildConfigId, dependency.DependencyBuildConfigId);

            string requestUri = string.Format("/app/rest/buildTypes/id:{0}", dependency.DependencyBuildConfigId);

            BuildConfigSummary buildConfig = await _http.Get <BuildConfigSummary>(requestUri);

            var dependencyDefinition = new DependencyDefinition
            {
                Id         = "0",
                Type       = "artifact_dependency",
                Properties = new Properties
                {
                    Property = new PropertyList
                    {
                        new Property()
                        {
                            Name = "cleanDestinationDirectory", Value = dependency.CleanDestinationDirectory.ToString()
                        },
                        new Property()
                        {
                            Name = "pathRules", Value = dependency.PathRules
                        },
                        new Property()
                        {
                            Name = "revisionName", Value = dependency.RevisionName
                        },
                        new Property()
                        {
                            Name = "revisionValue", Value = dependency.RevisionValue
                        },
                    }
                },
                SourceBuildConfig = buildConfig
            };

            await CreateDependency(dependency.TargetBuildConfigId, dependencyDefinition);
        }
예제 #6
0
 public BuildConfigXmlGenerator WithArtifactDependency(CreateArtifactDependency artifactDependency)
 {
     BuildConfigXml.CreateArtifactDependency(artifactDependency);
     return(this);
 }