private async Task ResolveDependency(DependencyDefinition dependency, EscrowElement escrowElement)
        {
            Log.Debug("Trying to fetch dependency: {0}", dependency.SourceBuildConfig.Id);

            if (_builds.ContainsKey(dependency.SourceBuildConfig.Id))
            {
                Log.Info("Dependency already fetched. Skipping: {0}", dependency.SourceBuildConfig.Id);
                return;
            }

            EscrowArtifactDependency escrowArtifact =
                escrowElement.ArtifactDependencies.FirstOrDefault(x => x.BuildTypeId == dependency.SourceBuildConfig.Id);

            if (escrowArtifact == null)
            {
                Log.Info("Cannot find dependency defined in escrow docucment: {0}", dependency.SourceBuildConfig.Id);
                return;
            }

            Build build = await _client.Builds.ById(escrowArtifact.Id);

            lock (_builds)
            {
                _builds.Add(build.BuildTypeId, BuildInfo.FromBuild(build));
            }

            Log.Debug("Downloading artifacts from: {0}-{1}", build.BuildTypeId, build.Number);

            List <ArtifactRule> artifactRules = GetArtifactRules(dependency);

            string basePath = _fileSystem.GetWorkingDirectory();

            if (string.IsNullOrWhiteSpace(basePath))
            {
                basePath = ".";
            }

            List <PathFilePair> files = new List <PathFilePair>();

            foreach (ArtifactRule artifactRule in artifactRules)
            {
                files.AddRange(await FetchFileListForArtifactRule(artifactRule, build, basePath));
            }

            DownloadFiles(files);

            Log.Debug("Done fetching dependency for: {0}", dependency.SourceBuildConfig.Id);
        }
示例#2
0
        private async Task ResolveDependency(DependencyDefinition dependency, string tag)
        {
            Log.Debug("Trying to fetch dependency: {0}", dependency.SourceBuildConfig.Id);

            if (_builds.ContainsKey(dependency.SourceBuildConfig.Id))
            {
                Log.Info("Dependency already fetched. Skipping: {0}", dependency.SourceBuildConfig.Id);
                return;
            }

            Build build;

            if (dependency.Properties.Property["revisionName"].Value == "buildNumber")
            {
                build = await _client.Builds.ByNumber(dependency.Properties.Property["revisionValue"].Value, dependency.SourceBuildConfig.Id);
            }
            else
            {
                build = await _client.Builds.LastSuccessfulBuildFromConfig(dependency.SourceBuildConfig.Id, tag);
            }

            lock (_builds)
            {
                _builds.Add(build.BuildTypeId, BuildInfo.FromBuild(build));
            }

            Log.Debug("Downloading artifacts from: {0}-{1}", build.BuildTypeId, build.Number);

            List <ArtifactRule> artifactRules = GetArtifactRules(dependency);

            //create fake files with the reference to the TC resources in order to download.
            List <PathFilePair> files = artifactRules.Select(x => new PathFilePair
            {
                File = x.CreateTeamCityFileReference(build.Href + "/artifacts/content/"),
                Path = Path.Combine(".", x.Dest)
            }).ToList();

            DownloadFiles(files);

            Log.Debug("Done fetching dependency for: {0}", dependency.SourceBuildConfig.Id);
        }