private TestRunContext CreateTestRunContext() { string releaseUri = null; string releaseEnvironmentUri = null; string teamProject = _executionContext.Variables.System_TeamProject; string owner = _executionContext.Variables.Build_RequestedFor; string buildUri = _executionContext.Variables.Build_BuildUri; int buildId = _executionContext.Variables.Build_BuildId ?? 0; string pullRequestTargetBranchName = _executionContext.Variables.System_PullRequest_TargetBranch; string stageName = _executionContext.Variables.System_StageName; string phaseName = _executionContext.Variables.System_PhaseName; string jobName = _executionContext.Variables.System_JobName; int stageAttempt = _executionContext.Variables.System_StageAttempt ?? 0; int phaseAttempt = _executionContext.Variables.System_PhaseAttempt ?? 0; int jobAttempt = _executionContext.Variables.System_JobAttempt ?? 0; //Temporary fix to support publish in RM scenarios where there might not be a valid Build ID associated. //TODO: Make a cleaner fix after TCM User Story 401703 is completed. if (buildId == 0) { _platform = _configuration = null; } if (!string.IsNullOrWhiteSpace(_executionContext.Variables.Release_ReleaseUri)) { releaseUri = _executionContext.Variables.Release_ReleaseUri; releaseEnvironmentUri = _executionContext.Variables.Release_ReleaseEnvironmentUri; } // If runName is not provided by the task, then create runName from testRunner name and buildId. string runName = String.IsNullOrWhiteSpace(_runTitle) ? String.Format("{0}_TestResults_{1}", _testRunner, buildId) : _runTitle; StageReference stageReference = new StageReference() { StageName = stageName, Attempt = Convert.ToInt32(stageAttempt) }; PhaseReference phaseReference = new PhaseReference() { PhaseName = phaseName, Attempt = Convert.ToInt32(phaseAttempt) }; JobReference jobReference = new JobReference() { JobName = jobName, Attempt = Convert.ToInt32(jobAttempt) }; PipelineReference pipelineReference = new PipelineReference() { PipelineId = buildId, StageReference = stageReference, PhaseReference = phaseReference, JobReference = jobReference }; TestRunContext testRunContext = new TestRunContext( owner: owner, platform: _platform, configuration: _configuration, buildId: buildId, buildUri: buildUri, releaseUri: releaseUri, releaseEnvironmentUri: releaseEnvironmentUri, runName: runName, testRunSystem: _testRunSystem, buildAttachmentProcessor: new CodeCoverageBuildAttachmentProcessor(), targetBranchName: pullRequestTargetBranchName, pipelineReference: pipelineReference ); return(testRunContext); }
private void ContextAddItemClicked(object sender, ToolItemEventArgs e) { var item = e.Item; DBItem row = null; object tag = tree.SelectedDBItem; if (item.Name == "Work") { row = new Work(); } else if (item.Name == "Work Stage") { row = new Stage(); if (tag is Work) { ((Stage)row).Work = (Work)tag; } } else if (item.Name == "Stage Parameter") { row = new StageParam(); if (tag is Stage) { ((StageParam)row).Stage = (Stage)tag; } } else if (item.Name == "Stage Procedure") { row = new StageProcedure(); if (tag is Stage) { ((StageParam)row).Stage = (Stage)tag; } } else if (item.Name == "Stage Reference") { row = new StageReference(); if (tag is Stage) { ((StageParam)row).Stage = (Stage)tag; } } else if (item.Name == "Group") { row = new UserGroup(); } else if (item.Name == "Template") { row = new Template(); if (tag is Template) { ((Template)row).Parent = (Template)tag; } } else if (item.Name == "Template Data") { row = new TemplateData(); if (tag is Template) { ((TemplateData)row).Template = (Template)tag; } } else if (item.Name == "User") { row = new User(); if (tag is Department) { ((User)row).Department = (Department)tag; } else if (tag is Position) { ((User)row).Position = (Position)tag; } //row.Access.Create foreach (var access in row.Access.Items.ToList()) { row.Access.Add(access.Group, access.Access & ~AccessType.Create); } } else if (item.Name == "Scheduler") { row = new Scheduler(); if (tag is DBProcedure) { ((Scheduler)row).Procedure = (DBProcedure)tag; } } ShowItem(row); }