private static string GetTenantSizePipelineVariableName(TenantSize tenantSize) { //locate the right variable var variableName = $"{tenantSize.ToString()}Tenants"; return(variableName); }
public VstsReleaseDefinition(VstsBuildDefinition buildDefinition, string tenantCode, TenantSize tenantSize, bool ringBased) { BuildDefinition = buildDefinition; TenantCode = tenantCode; TenantSize = tenantSize; RingBased = ringBased; State = EntityStateEnum.NotCreated; }
private async Task <ReleaseDefinition> RemoveTenantFromRingPipeline(string targetProject, string definitionName, string tenantCode, TenantSize tenantSize) { var definition = await _releaseHttpClient.LoadDefinitionByNameIfExists(targetProject, definitionName); if (definition == null) { throw new Exception($"Vsts Project {targetProject} does not contain release pipeline {definitionName}"); } var varName = GetTenantSizePipelineVariableName(tenantSize); if (!definition.Variables.ContainsKey(varName)) { throw new Exception($"Definition #{definition.Name} does not contain expected variable {varName}"); } var tenantSubString = GetTenantPipelineVariableDefinition(tenantCode, 11111); //TODO: link to port management var varValue = definition.Variables[varName].Value; varValue = varValue.Replace(tenantSubString, string.Empty); varValue = varValue.Replace($"{TenantPipelineVariableSeparator}{TenantPipelineVariableSeparator}", $"{TenantPipelineVariableSeparator}"); varValue = varValue.Trim(TenantPipelineVariableSeparator); definition.Variables[varName].Value = varValue; return(definition); }