Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ jobs:
Write-Host "##vso[task.setvariable variable=InternalVariableGroups]$internalVariableGroups"
Write-Host "##vso[task.setvariable variable=TestVariableGroups]$testVariableGroups"
Write-Host "##vso[task.setvariable variable=TestServiceConnections]$testServiceConnections"
Write-Host "##vso[task.setvariable variable=InternalServiceConnections]$internalServviceConnections"
Write-Host "##vso[task.setvariable variable=InternalServiceConnections]$internalServiceConnections"
Write-host "##vso[task.setvariable variable=GeneratePublicCIPipeline]$generatePublicCIPipeline"
Write-Host "##vso[task.setvariable variable=GenerateUnifiedWeekly]$generateUnifiedWeekly"
displayName: Setup pipeline generation variables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public async Task<ExitCondition> RunAsync(
return ExitCondition.DuplicateComponentsFound;
}

var updatedDefinitions = new List<BuildDefinition>();
var definitions = new List<BuildDefinition>();
foreach (var component in components)
{
logger.LogInformation("Processing component '{0}' in '{1}'.", component.Name, component.Path);
Expand All @@ -202,7 +202,7 @@ public async Task<ExitCondition> RunAsync(
OpenBrowser(definition.GetWebUrl());
}

updatedDefinitions.Add(definition);
definitions.Add(definition);
}
}

Expand All @@ -216,8 +216,8 @@ public async Task<ExitCondition> RunAsync(
var pipelines = pipelinePermissions["pipelines"].AsArray();
var pipelineIdsWithPermissions = new HashSet<int>(pipelines.Select(p => p["id"].GetValue<int>()));

bool needsUpdate = false;
foreach (var definition in updatedDefinitions)
int definitionsToAdd = 0;
foreach (var definition in definitions)
{
// Check this pipeline has permissions
if (!pipelineIdsWithPermissions.Contains(definition.Id))
Expand All @@ -232,12 +232,15 @@ public async Task<ExitCondition> RunAsync(
}
);

needsUpdate = true;
definitionsToAdd++;
}
}

if (needsUpdate)
logger.LogInformation("'{0}' pipelines already have permissions to service connection '{1}'. Need to grant permission to '{2}' more.", pipelineIdsWithPermissions.Count, serviceConnection.Id, definitionsToAdd);

if (definitionsToAdd > 0)
{
logger.LogInformation("Granting permissions for '{0}' definitions to service connection '{1}'.", definitionsToAdd, serviceConnection.Id);
// Update the permissions if we added anything
await context.UpdatePipelinePermissionsAsync(serviceConnection.Id, pipelinePermissions, cancellationToken);
}
Expand Down
Loading