Exemple #1
0
        /// <inheritdoc />
        public async Task <Release> CreateReleaseAsync(string account, string teamProject, int definitionId, OAuthToken token)
        {
            account.ThrowIfNullOrWhiteSpace(nameof(account));
            teamProject.ThrowIfNullOrWhiteSpace(nameof(teamProject));
            definitionId.ThrowIfSmallerOrEqual(nameof(definitionId));
            token.ThrowIfNull(nameof(token));

            ReleaseDefinition definition;

            using (var client = await this.ConnectAsync <ReleaseHttpClient2>(token, account))
            {
                definition = await client.GetReleaseDefinitionAsync(teamProject, definitionId);
            }

            var metadatas = new List <ArtifactMetadata>();

            using (var client = await this.ConnectAsync <BuildHttpClient>(token, account))
            {
                foreach (var artifact in definition.Artifacts.Where(a => string.Equals(a.Type, ArtifactTypes.BuildArtifactType, StringComparison.OrdinalIgnoreCase)))
                {
                    var definitions = new List <int> {
                        Convert.ToInt32(artifact.DefinitionReference["definition"].Id)
                    };
                    var builds = await client.GetBuildsAsync2(teamProject, definitions);

                    var build = builds.OrderByDescending(b => b.LastChangedDate).FirstOrDefault();

                    if (build == null)
                    {
                        continue;
                    }

                    var metadata = new ArtifactMetadata
                    {
                        Alias             = artifact.Alias,
                        InstanceReference = new BuildVersion {
                            Id = build.Id.ToString()
                        }
                    };

                    metadatas.Add(metadata);
                }
            }

            using (var client = await this.ConnectAsync <ReleaseHttpClient2>(token, account))
            {
                var metaData = new ReleaseStartMetadata {
                    DefinitionId = definitionId, Artifacts = metadatas
                };
                return(await client.CreateReleaseAsync(metaData, teamProject));
            }
        }
 private static VstsProfile CreateVstsProfile(IEnumerable <Account> accounts, Microsoft.VisualStudio.Services.Profile.Profile profile, OAuthToken token)
 {
     return(new VstsProfile
     {
         Accounts = accounts.Select(a => a.AccountName).ToList(),
         DisplayName = profile.DisplayName,
         EmailAddress = profile.EmailAddress,
         Id = profile.Id,
         Token = token
     });
 }
Exemple #3
0
        /// <inheritdoc />
        public async Task <Release> GetReleaseAsync(string account, string teamProject, int id, OAuthToken token)
        {
            account.ThrowIfNullOrWhiteSpace(nameof(account));
            teamProject.ThrowIfNullOrWhiteSpace(nameof(teamProject));
            id.ThrowIfSmallerOrEqual(nameof(id));
            token.ThrowIfNull(nameof(token));

            using (var client = await this.ConnectAsync <ReleaseHttpClient2>(token, account))
            {
                return(await client.GetReleaseAsync(teamProject, id));
            }
        }
Exemple #4
0
        /// <inheritdoc />
        public async Task <Build> QueueBuildAsync(string account, string teamProject, int definitionId, OAuthToken token)
        {
            account.ThrowIfNullOrWhiteSpace(nameof(account));
            teamProject.ThrowIfNullOrWhiteSpace(nameof(teamProject));
            definitionId.ThrowIfSmallerOrEqual(nameof(definitionId));
            token.ThrowIfNull(nameof(token));

            using (var client = await this.ConnectAsync <BuildHttpClient>(token, account))
            {
                var build = new Build {
                    Definition = new BuildDefinitionReference {
                        Id = definitionId
                    }
                };

                return(await client.QueueBuildAsync(build, teamProject));
            }
        }
Exemple #5
0
        /// <inheritdoc />
        public async Task <IList <ReleaseDefinition> > GetReleaseDefinitionsAsync(string account, string teamProject, OAuthToken token)
        {
            account.ThrowIfNullOrWhiteSpace(nameof(account));
            teamProject.ThrowIfNullOrWhiteSpace(nameof(teamProject));
            token.ThrowIfNull(nameof(token));

            using (var client = await this.ConnectAsync <ReleaseHttpClient2>(token, account))
            {
                return(await client.GetReleaseDefinitionsAsync(teamProject));
            }
        }
Exemple #6
0
        /// <inheritdoc />
        public async Task <IList <TeamProjectReference> > GetProjects(string account, OAuthToken token)
        {
            account.ThrowIfNullOrWhiteSpace(nameof(account));
            token.ThrowIfNull(nameof(token));

            using (var client = await this.ConnectAsync <ProjectHttpClient>(token, account))
            {
                var results = await client.GetProjects();

                return(results.ToList());
            }
        }
Exemple #7
0
        /// <inheritdoc/>
        public async Task <IList <BuildDefinitionReference> > GetBuildDefinitionsAsync(string account, string teamProject, OAuthToken token)
        {
            account.ThrowIfNullOrWhiteSpace(nameof(account));
            teamProject.ThrowIfNullOrWhiteSpace(nameof(teamProject));
            token.ThrowIfNull(nameof(token));

            using (var client = await this.ConnectAsync <BuildHttpClient>(token, account))
            {
                return(await client.GetDefinitionsAsync(teamProject, name : null));
            }
        }