Exemple #1
0
        public async Task <IEnumerable <string> > GetSuggestionsAsync(IComponentConfiguration config)
        {
            var credentialName = config["CredentialName"];

            if (string.IsNullOrEmpty(credentialName))
            {
                return(Enumerable.Empty <string>());
            }

            var credentials = GitLabCredentials.TryCreate(credentialName, config);

            if (credentials == null)
            {
                return(Enumerable.Empty <string>());
            }

            string ownerName = AH.CoalesceString(credentials.GroupName, credentials.UserName);

            if (string.IsNullOrEmpty(ownerName))
            {
                return(Enumerable.Empty <string>());
            }

            var client = new GitLabClient(credentials.ApiUrl, credentials.UserName, credentials.Password, credentials.GroupName);
            var groups = await client.GetGroupsAsync(CancellationToken.None).ConfigureAwait(false);

            var names = from m in groups
                        let name = m["full_path"]?.ToString()
                                   where !string.IsNullOrEmpty(name)
                                   orderby name
                                   select name;

            return(names);
        }
Exemple #2
0
        public async Task <IEnumerable <string> > GetSuggestionsAsync(IComponentConfiguration config)
        {
            var credentialName = config["CredentialName"];

            if (string.IsNullOrEmpty(credentialName))
            {
                return(Enumerable.Empty <string>());
            }

            var credentials = GitLabCredentials.TryCreate(credentialName, config);

            if (credentials == null)
            {
                return(Enumerable.Empty <string>());
            }

            string ownerName      = AH.CoalesceString(credentials.GroupName, credentials.UserName);
            string repositoryName = AH.CoalesceString(config["ProjectName"], credentials.ProjectName);

            if (string.IsNullOrEmpty(ownerName) || string.IsNullOrEmpty(repositoryName))
            {
                return(Enumerable.Empty <string>());
            }

            var client = new GitLabClient(credentials.ApiUrl, credentials.UserName, credentials.Password, credentials.GroupName);

            var milestones = await client.GetMilestonesAsync(repositoryName, "open", CancellationToken.None).ConfigureAwait(false);

            var titles = from m in milestones
                         let title                     = m["title"]?.ToString()
                                               let iid = m.Value <int?>("iid")
                                                         where !string.IsNullOrEmpty(title) && iid.HasValue
                                                         orderby iid descending
                                                         select title;

            if (SDK.ProductName == "BuildMaster")
            {
                titles = new[] { "$ReleaseName", "$ReleaseNumber" }.Concat(titles);
            }

            return(titles);
        }
Exemple #3
0
        public async Task <IEnumerable <string> > GetSuggestionsAsync(IComponentConfiguration config)
        {
            var credentialName = config["CredentialName"];

            if (string.IsNullOrEmpty(credentialName))
            {
                return(Enumerable.Empty <string>());
            }

            var credentials = GitLabCredentials.TryCreate(credentialName, config);

            if (credentials == null)
            {
                return(Enumerable.Empty <string>());
            }

            string ownerName = AH.CoalesceString(credentials.GroupName, credentials.UserName);

            if (string.IsNullOrEmpty(ownerName))
            {
                return(Enumerable.Empty <string>());
            }

            var client = new GitLabClient(credentials.ApiUrl, credentials.UserName, credentials.Password, credentials.GroupName);
            var repos  = await client.GetProjectsAsync(CancellationToken.None).ConfigureAwait(false);


            var names = from m in repos
                        let name = m["path"]?.ToString()
                                   where !string.IsNullOrEmpty(name)
                                   orderby name
                                   select name;

            if (SDK.ProductName == "BuildMaster")
            {
                names = new[] { $"$ApplicationName" }.Concat(names);
            }
            return(names);
        }