Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish to multiple channels - Part 2 #6754

Merged
merged 8 commits into from
Jan 15, 2021
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
4 changes: 2 additions & 2 deletions eng/common/post-build/publish-using-darc.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ param(

try {
. $PSScriptRoot\post-build-utils.ps1
# Hard coding darc version till the next arcade-services roll out, cos this version has required API changes for darc add-build-to-channel
$darc = Get-Darc "1.1.0-beta.20418.1"

$darc = Get-Darc

$optionalParams = [System.Collections.ArrayList]::new()

Expand Down
2 changes: 1 addition & 1 deletion eng/promote-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ stages:
exit 1
}

$channels = ${Env:PromoteToChannelIds} -split ","
$channels = ${Env:PromoteToChannelIds} -split "-"
foreach ($channelId in $channels) {
$channelApiEndpoint = "$(MaestroApiEndPoint)/api/channels/${channelId}?api-version=$(MaestroApiVersion)"
$channelInfo = try { Invoke-WebRequest -Method Get -Uri $channelApiEndpoint -Headers $apiHeaders | ConvertFrom-Json } catch { Write-Host "Error: $_" }
Expand Down
8 changes: 6 additions & 2 deletions src/Microsoft.DotNet.Build.Tasks.Feed/src/BlobFeedAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,12 @@ public async Task UploadAssetAsync(
}
else
{
Log.LogMessage($"Uploading {item} to {relativeBlobPath}.");
await blobUtils.UploadBlockBlobAsync(item.ItemSpec, relativeBlobPath);
using (FileStream stream =
new FileStream(item.ItemSpec, FileMode.Open, FileAccess.Read, FileShare.Read))
{
Log.LogMessage($"Uploading {item} to {relativeBlobPath}.");
await blobUtils.UploadBlockBlobAsync(item.ItemSpec, relativeBlobPath, stream);
}
}
}
catch (Exception exc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public async Task<bool> ExecuteAsync()
IMaestroApi client = ApiFactory.GetAuthenticated(MaestroApiEndpoint, BuildAssetRegistryToken);
Maestro.Client.Models.Build buildInformation = await client.Builds.GetBuildAsync(BARBuildId);

var targetChannelsIds = TargetChannels.Split(',').Select(ci => int.Parse(ci));
var targetChannelsIds = TargetChannels.Split('-').Select(ci => int.Parse(ci));

foreach (var targetChannelId in targetChannelsIds)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public override async Task<bool> ExecuteAsync()
{
List<int> targetChannelsIds = new List<int>();

foreach (var channelIdStr in TargetChannels.Split(','))
foreach (var channelIdStr in TargetChannels.Split('-'))
{
if (!int.TryParse(channelIdStr, out var channelId))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static string CalculateMD5(string filename)
}
}

public async Task UploadBlockBlobAsync(string filePath, string blobPath)
public async Task UploadBlockBlobAsync(string filePath, string blobPath, Stream stream)
{
BlobClient blob = GetBlob(blobPath.Replace("\\", "/"));
BlobHttpHeaders headers = GetBlobHeadersByExtension(filePath);
Expand All @@ -83,7 +83,7 @@ public async Task UploadBlockBlobAsync(string filePath, string blobPath)
try
{
await blob.UploadAsync(
filePath,
stream,
headers)
.ConfigureAwait(false);
return true;
Expand Down