Example #1
0
        public async Task <int> CreateDefs()
        {
            var repos = (await GetRepos()).OrderBy(r => r.Name).ToList();

            log.LogInformation($"Found {repos.Count} repos");

            var buildDefs = await GetBuildDefs();

            log.LogInformation($"{buildDefs.Count} build defs already exist");

            int created = 0;

            foreach (var r in repos)
            {
                try
                {
                    if (!buildDefs.Contains(CiBuildManager.BuildDefName(r.Name)))
                    {
                        log.LogInformation($"Creating CI build for {r.Name}....");

                        var result = await CreateDefinition(r.Name, new Uri(r.CloneUrl));

                        created++;

                        log.LogInformation(result ? "CREATED" : "SKIPPED");
                    }
                }
                catch (Exception ex)
                {
                    log.LogInformation($"ERROR: {ex.Message}");
                }
            }

            return(created);
        }