public override async Task <IList <Project> > GetProjects(string address) { var projects = new List <Project>(); var owner = TravisAPI.GetOwnerName(TravisAPI.GetSlug(address)); if (string.IsNullOrEmpty(owner)) { return(projects); } var repositoryFromAddress = TravisAPI.GetRepositoryName(TravisAPI.GetSlug(address)); if (string.IsNullOrWhiteSpace(repositoryFromAddress)) { // try to fetch all repositories for an organization var repositories = await TravisAPI.GetRepositories(address); foreach (var repository in repositories) { if (repository == null || string.IsNullOrWhiteSpace(repository.Name)) { continue; } projects.Add(await AddProjects(owner, repository.Name)); } } else { projects.Add(await AddProjects(owner, repositoryFromAddress)); } return(projects); }
private static async Task <Project> AddProjects(string owner, string repository) { var jobs = await TravisAPI.GetJobs(owner, repository); if (!jobs.Any()) { return(null); } var parent = new Project() { Name = jobs.FirstOrDefault().Repository?.Name, Address = jobs.FirstOrDefault().Repository.Url }; foreach (var job in jobs) { parent.Children.Add(new Project() { Name = job.Name, Address = job.Url }); } return(parent); }
public override void Configure(Project project, IConfigurationItemProvider configurationItemsSupport, string serverAddress) { configurationItemsSupport.GetConfigurationByKey(Connector.ServerAddress).Value = TravisAPI.OpenSourceUrl; configurationItemsSupport.GetConfigurationByKey(nameof(TravisConnector.Owner)).Value = TravisAPI.GetOwnerName(TravisAPI.GetSlug(serverAddress)); configurationItemsSupport.GetConfigurationByKey(nameof(TravisConnector.Repository)).Value = TravisAPI.GetRepositoryName(TravisAPI.GetSlug(serverAddress)); configurationItemsSupport.GetConfigurationByKey(nameof(TravisConnector.Branch)).Value = project.Name; }