Beispiel #1
0
        private async Task OnConnectAsync()
        {
            IsConnecting = true;

            try
            {
                Application.Current.Dispatcher.Invoke(() => { BuildDefinitions.Clear(); });

                var buildDefinitions = await BuildProvider.GetBuildDefinitionsAsync(MonitorSettings).ConfigureAwait(false);

                if (buildDefinitions.IsSuccessStatusCode)
                {
                    Application.Current.Dispatcher.Invoke(() => { ApplyBuildDefinitions(buildDefinitions.Data); });
                    StatusText = String.Empty;
                    ShowPersonalAccessTokenInput = false;
                }
                else
                {
                    AccessTokenInputWhenUnauthorized(buildDefinitions.StatusCode);
                }
            }
            catch (AdvancedHttpRequestException ex)
            {
                AccessTokenInputWhenUnauthorized(ex.StatusCode);
            }
            catch (Exception ex)
            {
                StatusText = ex.Message;
            }

            IsConnecting = false;
        }
Beispiel #2
0
        public void ShouldReturnBuildDefinitions()
        {
            // arrange
            const string project             = "StricklandPropaneTanks";
            const string buildDefinitionName = "StricklandPropaneSpatulas";
            const int    buildDefinitionId   = 234;

            IBuildDefinitionsFactory buildDefinitionsFactory = new FakeBuildDefinitionsFactory(1, new List <Definition> {
                new Definition(buildDefinitionId, buildDefinitionName)
            });
            BuildDefinitionController buildDefinitionController = new Privateer().Object <BuildDefinitionController>(buildDefinitionsFactory);

            // act
            OkObjectResult okObjectResult = (OkObjectResult)buildDefinitionController.BuildDefinitions(project);

            // assert
            okObjectResult.StatusCode.Should().Be(200);
            BuildDefinitions buildDefinitions = (BuildDefinitions)okObjectResult.Value;
            JObject          jObject          = JObject.Parse(JsonConvert.SerializeObject(buildDefinitions));

            jObject["count"].Value <int>().Should().Be(1);
            jObject["items"].Should().HaveCount(1);
            jObject["items"][0]["id"].Value <int>().Should().Be(buildDefinitionId);
            jObject["items"][0]["name"].Value <string>().Should().Be(buildDefinitionName);
        }
Beispiel #3
0
        private async Task <List <string> > BuildsThatUseVariableGroupAsync(int variableGroupId)
        {
            List <string> builds = new List <string>();

            BuildDefinitions buildDefinitions = await GetBuildDefinitionsAsync();

            foreach (var buildDefinition in buildDefinitions.value)
            {
                Build build = await GetBuild(buildDefinition.id);

                if (build.variableGroups != null)
                {
                    foreach (VariableGroup variablegroup in build.variableGroups)
                    {
                        if (variablegroup.id == variableGroupId)
                        {
                            builds.Add(build.name);
                            break;
                        }
                    }
                }
            }

            if (builds.Count > 0)
            {
                return(builds);
            }
            else
            {
                return(null);
            }
        }
        private void PopulateBackgroundWorkerOnDoWork(object sender, DoWorkEventArgs doWorkEventArgs)
        {
            this.Logger().Trace("Begin Populate");


            Application.Current.Dispatcher.Invoke(() =>
            {
                IsPopulating = true;
                BuildDefinitions.Clear();
            }, DispatcherPriority.Normal);

            IBuildDefinition[] buildDefinitions;
            if (teamPilgrimServiceModelProvider.TryGetBuildDefinitionsByProjectName(out buildDefinitions, _collection, _project.Name))
            {
                foreach (var buildDefinitionModel in buildDefinitions.Select(definition => new BuildDefinitionModel(this, definition)))
                {
                    var localScopeModel = buildDefinitionModel;
                    Application.Current.Dispatcher.Invoke(() => BuildDefinitions.Add(localScopeModel));
                }
            }

            Application.Current.Dispatcher.Invoke(() => IsPopulating = false, DispatcherPriority.Normal);

            this.Logger().Trace("End Populate");
        }
Beispiel #5
0
        private void ApplyBuildDefinitions(IEnumerable <IBuildDefinition> buildDefinitions)
        {
            BuildDefinitions.AddRange(buildDefinitions.Select(buildDefinition =>
            {
                var vm = new BuildDefinitionViewModel(buildDefinition);

                var definition = MonitorSettings.SelectedBuildDefinitions.SingleOrDefault(a => a.Id == vm.BuildDefinition.Id);
                if (definition != null && this.buildDefinitionEqualityComparer.Equals(definition, vm.BuildDefinition))
                {
                    vm.IsSelected = true;
                }

                return(vm);
            }));

            var obsoleteDefinitions = MonitorSettings.SelectedBuildDefinitions.Where(a => BuildDefinitions.All(x => x.BuildDefinition.Id != a.Id)).ToList();

            foreach (var obsoleteDefinition in obsoleteDefinitions)
            {
                var vm = new BuildDefinitionViewModel(obsoleteDefinition)
                {
                    IsDeleted  = true,
                    IsSelected = true
                };
                BuildDefinitions.Add(vm);
            }
        }
 private void DeleteBuildDefinition(BuildDefinitionModel buildDefinitionModel)
 {
     if (teamPilgrimServiceModelProvider.TryDeleteBuildDefinition(buildDefinitionModel.Definition))
     {
         BuildDefinitions.Remove(buildDefinitionModel);
     }
 }
        private void QueueBuild(BuildDefinitionModel buildDefinitionModel)
        {
            var definitionModel = buildDefinitionModel ?? BuildDefinitions.FirstOrDefault();

            //TODO: SG 11/3/2012 Fix this, I know this cannot be true
            Debug.Assert(definitionModel != null, "definitionModel != null");

            teamPilgrimVsService.QueueBuild(_project.Name, definitionModel.Definition.Uri);
        }
        private void CloneBuildDefinition(BuildDefinitionModel buildDefinitionModel)
        {
            IBuildDefinition buildDefinition;

            if (teamPilgrimServiceModelProvider.TryCloneQueryDefinition(out buildDefinition, _collection, _project, buildDefinitionModel.Definition))
            {
                BuildDefinitions.Add(new BuildDefinitionModel(this, buildDefinition));
            }
        }
Beispiel #9
0
        async void GetDefinitions()
        {
            Working = true;
            await Task.Run(() =>
            {
                buildDefs = TfsShared.Instance.BuildServer.QueryBuildDefinitions(TfsShared.Instance.ProjectInfo.Name, QueryOptions.All);
            });

            foreach (var def in buildDefs)
            {
                BuildDefinitions.Add(def);
            }
            Working = false;
        }
Beispiel #10
0
        public static async Task <BuildDefinitions> GetBuildDefinitionsAsync()
        {
            try
            {
                var jsonText = await ExecuteJsonAsync(String.Format("https://dev.azure.com/{0}/{1}/_apis/build/definitions", Properties.Settings.Default.Organisation, Properties.Settings.Default.ProjectName));

                BuildDefinitions buildDefinitions = JsonConvert.DeserializeObject <BuildDefinitions>(jsonText);
                return(buildDefinitions);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                throw;
            }
        }
Beispiel #11
0
        private async Task <BuildDefinitions> GetBuildDefinitionsAsync()
        {
            try
            {
                var jsonText = await ExecuteJsonAsync(String.Format("https://dev.azure.com/{0}/{1}/_apis/build/definitions", _config.GetValue <string>("AzureDevOps:Organisation"), _config.GetValue <string>("AzureDevOps:ProjectName")));

                BuildDefinitions buildDefinitions = JsonConvert.DeserializeObject <BuildDefinitions>(jsonText);
                return(buildDefinitions);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                throw;
            }
        }
Beispiel #12
0
        public void GivenProjectName_WhenAskingToCreate_ShouldHydrateBuildDefinitions()
        {
            // arrange
            IBuildDefinitionsFactory buildDefinitionsFactory = new BuildDefinitionsFactory(_vstsHttpService, _configuration);

            // act
            BuildDefinitions buildDefinitions = buildDefinitionsFactory.Create(Project);

            // assert

            JObject jBuildDefinitions = JObject.Parse(JsonConvert.SerializeObject(buildDefinitions));

            jBuildDefinitions["count"].Value <int>().Should().Be(3);

            jBuildDefinitions["items"][0]["id"].Value <int>().Should().Be(3);
            jBuildDefinitions["items"][0]["name"].Value <string>().Should().Be("NaturalGasToPropaneAdapters");
        }
Beispiel #13
0
        public override void Save()
        {
            if (IsInEditMode)
            {
                base.Save();

                MonitorSettings.SelectedBuildDefinitions.Clear();
                var selected = BuildDefinitions.Where(a => a.IsSelected && !a.IsDeleted);
                foreach (var viewModel in selected)
                {
                    MonitorSettings.SelectedBuildDefinitions.Add(viewModel.BuildDefinition);
                }

                IsInEditMode = false;

                UpdateSelectedCollection();
                BuildDefinitions.Clear();
            }
        }
Beispiel #14
0
    }         // BlenderConnections()

    #endregion

    void FinalizeAsset()
    {
        List <GameObject> needsParent = new List <GameObject>();
        GameObject        temp;
        MeshFilter        mf;
        int i, j, k, tempid, pId;

        for (i = 0; i < impModels.Count; i++)
        {
            temp = new GameObject(impModels[i].name);
            temp.AddComponent <MeshRenderer>();
            mf = temp.AddComponent <MeshFilter>();

            UnifyVerts(impModels[i]);

            mf.mesh.vertices  = impModels[i].GetVerts();
            mf.mesh.triangles = impModels[i].GetPolyVerts();
            mf.mesh.normals   = impModels[i].GetNorms();
            mf.mesh.uv        = impModels[i].GetUVs();

            temp.active = false;
            needsParent.Add(temp);
        }         // for

        //parent objects as necessary
        //also handles moved origin for convenience
        for (i = 0; i < needsParent.Count; i++)
        {
            tempid = FindMeshID(impModels[i].name);

            if (impMeshes[tempid].GetPID() == 0)
            {
                needsParent[i].transform.parent = baseGO.transform;
                continue;
            }             // if
            //parenting
            for (j = 0; j < impMeshes.Count; j++)
            {
                if (impMeshes[j].GetID() == impMeshes[tempid].GetPID())
                {
                    for (k = 0; k < impModels.Count; k++)
                    {
                        if (impModels[k].name.Equals(impMeshes[j].GetName()))
                        {
                            needsParent[i].transform.parent = needsParent[k].transform;
                            break;
                        } // if
                    }     // for
                    break;
                }         // if
            }             // for

            //origin moving
            for (j = 0; j < impMeshes.Count; j++)
            {
                if (needsParent[i].name.Equals(impMeshes[j].GetName()))
                {
                    if (impMeshes[j].GetOrig() != new Vector3(0f, 0f, 0f))
                    {
                        needsParent[i].transform.position += impMeshes[j].GetOrig();
                    } // if
                }     // if
            }         // for
        }             // for


        baseGO.active = false;
        BuildDefinitions.AddMesh(baseGO);
        impModels.Clear();
        impMeshes.Clear();
        needsParent.Clear();
    }     // FinalizeAsset()
Beispiel #15
0
        public static void Main(string[] args)
        {
            string PAT         = string.Empty;
            string accountName = string.Empty;
            string projectName = string.Empty;

            Console.WriteLine("Please enter Account Name");
            accountName = Console.ReadLine();

            Console.WriteLine("Please enter Personal access token");
            PAT = Console.ReadLine();

            Console.WriteLine("Please enter project name");
            projectName = Console.ReadLine();

            Configuration sourceconfig = new Configuration()
            {
                UriString = "https://" + accountName + ".visualstudio.com:", PersonalAccessToken = PAT, Project = projectName
            };

            VstsRestAPI.Configuration vstsAPIConfiguration = new VstsRestAPI.Configuration()
            {
                UriString = "https://" + accountName + ".visualstudio.com:", PersonalAccessToken = PAT, Project = projectName
            };

            ValidateLogin objLogin       = new ValidateLogin(vstsAPIConfiguration);
            bool          isValidAccount = objLogin.isValidAccount();

            if (isValidAccount)
            {
                Console.WriteLine("Generating templates....");
                Console.WriteLine();

                ExportQueries objQuery = new ExportQueries(vstsAPIConfiguration);
                //queryList = objQuery.GetQueries(projectName);
                objQuery.GetQueriesByPath(projectName, string.Empty);

                ExportDashboards objWidgetAndCharts = new ExportDashboards(vstsAPIConfiguration);
                objWidgetAndCharts.GetDashboard(projectName);
                Console.WriteLine("Queries and Dashboard JSONs are saved into Template folder");
                Console.WriteLine("");

                Teams objTeam = new Teams(vstsAPIConfiguration);
                objTeam.ExportTeams(projectName);
                Console.WriteLine("Teams JSON is saved into Template folder");
                Console.WriteLine("");

                SourceCode objSourceCode = new SourceCode(vstsAPIConfiguration);
                objSourceCode.ExportSourceCode(projectName);
                Console.WriteLine("ImportSourceCode JSON is saved into Template folder");
                Console.WriteLine("");

                BoardColumns objColumn = new BoardColumns(vstsAPIConfiguration);
                objColumn.ExportBoardColumns(projectName);
                Console.WriteLine("BoardColumn JSON file is saved into Template folder");
                Console.WriteLine("");

                GenerateWIFromSource wiql = new GenerateWIFromSource(sourceconfig, accountName);
                wiql.UpdateWorkItem();
                Console.WriteLine("Work item JSON files are saved into Templates folder");
                Console.WriteLine("");

                BuildDefinitions   objBuild   = new BuildDefinitions(vstsAPIConfiguration, accountName);
                ReleaseDefinitions objRelease = new ReleaseDefinitions(vstsAPIConfiguration, accountName);
                objBuild.ExportBuildDefinitions(projectName);
                objRelease.ExportReleaseDefinitions(projectName);
                Console.WriteLine("Build and Release Definitions are saved into Templates folder");
                Console.WriteLine("");

                CardFieldsAndCardStyles objCards = new CardFieldsAndCardStyles(vstsAPIConfiguration);
                objCards.GetCardFields(projectName);
                objCards.GetCardStyles(projectName);
                Console.WriteLine("CardField and CardStyle JSON files are saved into Templates folder");
                Console.WriteLine("");

                PullRequests objPullRequest = new PullRequests(vstsAPIConfiguration);
                objPullRequest.ExportPullRequests(projectName);
                Console.WriteLine("PullReqests and comments JSON files are saved into Templates folder");
                Console.WriteLine("");

                Console.WriteLine("Completed generating templates from " + projectName);
                var wait = Console.ReadLine();
            }
            else
            {
                Console.WriteLine("");
                Console.WriteLine("Invalid Account name or PAT, re-run the application and try again!");
                var wait = Console.ReadLine();
            }
        }
Beispiel #16
0
        public static async Task GetUnusedVariableGroups()
        {
            VariableGroups vGroups = await GetVariableGroupsAsync();

            ReleaseDefinitions releaseDefinitions = await GetReleaseDefinitionsAsync();

            List <VariableGroupsValue> groups = vGroups.value;
            List <int> usedGroups             = new List <int>();

            foreach (ReleaseDefinition rDef in releaseDefinitions.value)
            {
                Release release = await GetRelease(rDef.id);

                foreach (int variablegroupId in release.variableGroups)
                {
                    var g = groups.Find(x => x.id == variablegroupId);
                    if (g == null)
                    {
                        Console.WriteLine(string.Format("{0} is referencing a deleted variable group (id-{1})", rDef.name, variablegroupId));
                    }
                    else
                    {
                        usedGroups.Add(variablegroupId);
                    }
                }
                foreach (Environment environment in release.environments)
                {
                    foreach (int variablegroupId in environment.variableGroups)
                    {
                        var g = groups.Find(x => x.id == variablegroupId);
                        if (g == null)
                        {
                            Console.WriteLine(string.Format("{0} is referencing a deleted variable group (id-{1})", rDef.name, variablegroupId));
                        }
                        else
                        {
                            usedGroups.Add(variablegroupId);
                        }
                    }
                }
            }

            BuildDefinitions buildDefinitions = await GetBuildDefinitionsAsync();

            foreach (var buildDefinition in buildDefinitions.value)
            {
                Build build = await GetBuild(buildDefinition.id);

                if (build.variableGroups != null)
                {
                    foreach (VariableGroup variablegroup in build.variableGroups)
                    {
                        var g = groups.Find(x => x.id == variablegroup.id);
                        if (g == null)
                        {
                            Console.WriteLine(string.Format("{0} is referencing a deleted variable group (id-{1})", buildDefinition.name, variablegroup.id));
                        }
                        else
                        {
                            usedGroups.Add(variablegroup.id);
                        }
                    }
                }
            }

            bool used;

            foreach (var variableGroup in vGroups.value)
            {
                used = false;
                foreach (var usedGroup in usedGroups)
                {
                    if (variableGroup.id == usedGroup)
                    {
                        used = true;
                    }
                }
                if (used == false)
                {
                    Console.WriteLine(String.Format("'{0}' is not used - id {1}", variableGroup.name, variableGroup.id));
                }
            }
        }
Beispiel #17
0
        public static void Main(string[] args)
        {
            string PAT         = string.Empty;
            string accountName = string.Empty;
            string projectName = string.Empty;

            Console.WriteLine("Please enter Account Name");
            accountName = Console.ReadLine();

            Console.WriteLine("Please enter Personel access token");
            PAT = Console.ReadLine();

            Console.WriteLine("Please enter project name");
            projectName = Console.ReadLine();


            Configuration sourceconfig = new Configuration()
            {
                UriString = "https://" + accountName + ".visualstudio.com:", PersonalAccessToken = PAT, Project = projectName
            };

            VstsRestAPI.Configuration vstsAPIConfiguration = new VstsRestAPI.Configuration()
            {
                UriString = "https://" + accountName + ".visualstudio.com:", PersonalAccessToken = PAT, Project = projectName
            };

            Console.WriteLine("Generating templates....");
            Console.WriteLine();


            Dictionary <string, string> queryList = new Dictionary <string, string>();
            ExportQueries objQuery = new ExportQueries(vstsAPIConfiguration);

            //queryList = objQuery.GetQueries(projectName);
            queryList = objQuery.GetQueriesByPath(projectName, string.Empty);

            ExportWidgetsAndCharts objWidgetAndCharts = new ExportWidgetsAndCharts(vstsAPIConfiguration);

            objWidgetAndCharts.GetWidgetsAndCharts(projectName, queryList);
            Console.WriteLine("Queries and widget JSONs are saved into Template folder");
            Console.WriteLine("");


            Teams objTeam = new Teams(vstsAPIConfiguration);

            objTeam.ExportTeams(projectName);
            Console.WriteLine("Teams JSON is saved into Template folder");
            Console.WriteLine("");

            ServiceEndpoints objService = new ServiceEndpoints(vstsAPIConfiguration);

            string serviceEndPoint = string.Empty;

            serviceEndPoint = objService.ExportServiceEndPoints(projectName);
            Console.WriteLine("ServiceEndPoint JSONs are saved into Template folder");
            Console.WriteLine("");

            SourceCode objSourceCode = new SourceCode(vstsAPIConfiguration);

            objSourceCode.ExportSourceCode(projectName);
            Console.WriteLine("ImportSourceCode JSON is saved into Template folder");
            Console.WriteLine("");

            BoardColumns objColumn = new BoardColumns(vstsAPIConfiguration);

            objColumn.ExportBoardColumns(projectName);
            Console.WriteLine("BoardColumn JSON file is saved into Template folder");
            Console.WriteLine("");

            GenerateWIFromSource wiql = new GenerateWIFromSource(sourceconfig, accountName);

            wiql.UpdateWorkItem();
            Console.WriteLine("Work item JSON files are saved into Templates folder");
            Console.WriteLine("");

            BuildDefinitions   objBuild   = new BuildDefinitions(vstsAPIConfiguration, accountName);
            ReleaseDefinitions objRelease = new ReleaseDefinitions(vstsAPIConfiguration, accountName);

            objBuild.ExportBuildDefinitions(projectName);
            objRelease.ExportReleaseDefinitions(projectName, serviceEndPoint);
            Console.WriteLine("Build and Release Definitions are saved into Templates folder");
            Console.WriteLine("");

            CardFieldsAndCardStyles objCards = new CardFieldsAndCardStyles(vstsAPIConfiguration);

            objCards.GetCardFields(projectName);
            objCards.GetCardStyles(projectName);
            Console.WriteLine("CardField and CardStyle JSON files are saved into Templates folder");
            Console.WriteLine("");

            Iterations objIterations = new Iterations(vstsAPIConfiguration, accountName);

            objIterations.GetIterations();
            Console.WriteLine("iterations JSON file is saved into Templates folder");
            Console.WriteLine("");

            PullRequests objPullRequest = new PullRequests(vstsAPIConfiguration);

            objPullRequest.ExportPullRequests(projectName);
            Console.WriteLine("PullReqests and comments JSON files are saved into Templates folder");
            Console.WriteLine("");

            Console.WriteLine("Completed generating templates from " + projectName);
            var wait = Console.ReadLine();
        }
Beispiel #18
0
        /// <summary>
        /// project new state onto the current instance
        /// </summary>
        /// <param name="newState">new intended state</param>
        /// <param name="environments">list of environments to provision to</param>
        public void Update(Tenant newState, IEnumerable <DeploymentEnvironment> environments)
        {
            if (newState == null)
            {
                return;
            }

            Name       = newState.Name;
            TenantSize = newState.TenantSize;

            var newStateForks = newState.SourceRepos.Select(r => new SourceCodeRepository(r.SourceRepositoryName, Code, r.ProjectType, r.Fork)).ToList();

            //update forks and build definitions (1:1) - additions and removals
            newStateForks
            .Except(SourceRepos, ForkEqComparer)
            .ToList()
            .ForEach(f =>
            {
                f.TenantCode = Code;
                SourceRepos.Add(f);
                var bd = new VstsBuildDefinition(f, Code);
                BuildDefinitions.Add(bd);

                //for canary, no PROD env in non prod release pipeline
                var standardPipeline = new VstsReleaseDefinition(bd, Code, TenantSize, false)
                {
                    SkipEnvironments = !f.Fork ? new[] { DeploymentEnvironment.Prod } : new DeploymentEnvironment[] { }
                };
                ReleaseDefinitions.Add(standardPipeline);

                if (f.Fork)
                {
                    return;
                }

                //also initiate ring pipeline (if not fork)
                var ringPipeline = new VstsReleaseDefinition(bd, Code, TenantSize, true);
                ReleaseDefinitions.Add(ringPipeline);
            });

            SourceRepos
            .Except(newStateForks, ForkEqComparer)
            .ToList()
            .ForEach(f =>
            {
                f.State  = EntityStateEnum.ToBeDeleted;
                var bd   = BuildDefinitions.Single(b => Equals(b.SourceCode, f));
                bd.State = EntityStateEnum.ToBeDeleted;
                bd.ReleaseDefinitions.ForEach(d => d.State = EntityStateEnum.ToBeDeleted);
            });

            var environmentList = environments.ToList();

            if (!ResourceGroups.Any())
            {
                foreach (var environmentName in environmentList)
                {
                    // TODO: validate that the list of resource groups and their names
                    ResourceGroups.Add(new ResourceGroup(Code, environmentName, $"checkout-{Code}-{environmentName}"));
                }
            }

            if (!ManagedIdentities.Any())
            {
                foreach (var environmentName in environmentList)
                {
                    // TODO: validate the list of created managed identities and their names
                    ManagedIdentities.Add(new ManagedIdentity
                    {
                        TenantCode        = Code,
                        Environment       = environmentName,
                        IdentityName      = $"{Code}-{environmentName}",
                        ResourceGroupName = $"checkout-{Code}-{environmentName}",
                    });
                }
            }
        }