mirror of
https://github.com/actions/runner.git
synced 2025-12-10 12:36:23 +00:00
* Support downloading/publishing artifacts from Pipelines endpoint * Remove `Path` from everywhere * Remove unused JobId argument * PR feedback * More PR feedback
61 lines
2.0 KiB
C#
61 lines
2.0 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using GitHub.Actions.Pipelines.WebApi;
|
|
using GitHub.Services.WebApi;
|
|
using GitHub.Runner.Sdk;
|
|
using Pipelines = GitHub.Actions.Pipelines.WebApi;
|
|
|
|
namespace GitHub.Runner.Plugins.Artifact
|
|
{
|
|
// A client wrapper interacting with Pipelines's Artifact API
|
|
public class PipelinesServer
|
|
{
|
|
private readonly PipelinesHttpClient _pipelinesHttpClient;
|
|
|
|
public PipelinesServer(VssConnection connection)
|
|
{
|
|
ArgUtil.NotNull(connection, nameof(connection));
|
|
_pipelinesHttpClient = connection.GetClient<PipelinesHttpClient>();
|
|
}
|
|
|
|
// Associate the specified Actions Storage artifact with a pipeline
|
|
public async Task<Pipelines.ActionsStorageArtifact> AssociateActionsStorageArtifactAsync(
|
|
int pipelineId,
|
|
int runId,
|
|
long containerId,
|
|
string name,
|
|
long size,
|
|
CancellationToken cancellationToken = default(CancellationToken))
|
|
{
|
|
CreateArtifactParameters parameters = new CreateActionsStorageArtifactParameters()
|
|
{
|
|
Name = name,
|
|
ContainerId = containerId,
|
|
Size = size
|
|
};
|
|
|
|
return await _pipelinesHttpClient.CreateArtifactAsync(
|
|
parameters,
|
|
pipelineId,
|
|
runId,
|
|
cancellationToken: cancellationToken) as Pipelines.ActionsStorageArtifact;
|
|
}
|
|
|
|
// Get named Actions Storage artifact for a pipeline
|
|
public async Task<Pipelines.ActionsStorageArtifact> GetActionsStorageArtifact(
|
|
int pipelineId,
|
|
int runId,
|
|
string name,
|
|
CancellationToken cancellationToken)
|
|
{
|
|
return await _pipelinesHttpClient.GetArtifactAsync(
|
|
pipelineId,
|
|
runId,
|
|
name,
|
|
cancellationToken: cancellationToken) as Pipelines.ActionsStorageArtifact;
|
|
}
|
|
}
|
|
}
|