コード例 #1
0
        private async Task UploadArtifactAsync(
            IAsyncCommandContext context,
            Uri projectCollection,
            VssCredentials credentials,
            Guid projectId,
            long containerId,
            string containerPath,
            int buildId,
            string name,
            Dictionary <string, string> propertiesDictionary,
            string source,
            CancellationToken cancellationToken)
        {
            FileContainerServer fileContainerHelper = new FileContainerServer(projectCollection, credentials, projectId, containerId, containerPath);
            await fileContainerHelper.CopyToContainerAsync(context, source, cancellationToken);

            string fileContainerFullPath = StringUtil.Format($"#/{containerId}/{containerPath}");

            context.Output(StringUtil.Loc("UploadToFileContainer", source, fileContainerFullPath));

            BuildServer buildHelper = new BuildServer(projectCollection, credentials, projectId);
            var         artifact    = await buildHelper.AssociateArtifact(buildId, name, WellKnownArtifactResourceTypes.Container, fileContainerFullPath, propertiesDictionary, cancellationToken);

            context.Output(StringUtil.Loc("AssociateArtifactWithBuild", artifact.Id, buildId));
        }
コード例 #2
0
        private async Task UploadArtifactAsync(
            IAsyncCommandContext context,
            VssConnection connection,
            Guid projectId,
            long containerId,
            string containerPath,
            int buildId,
            string name,
            string jobId,
            Dictionary <string, string> propertiesDictionary,
            string source,
            CancellationToken cancellationToken)
        {
            FileContainerServer fileContainerHelper = new FileContainerServer(connection, projectId, containerId, containerPath);
            long size = await fileContainerHelper.CopyToContainerAsync(context, source, cancellationToken);

            propertiesDictionary.Add(ArtifactUploadEventProperties.ArtifactSize, size.ToString());

            string fileContainerFullPath = StringUtil.Format($"#/{containerId}/{containerPath}");

            context.Output(StringUtil.Loc("UploadToFileContainer", source, fileContainerFullPath));

            BuildServer buildHelper = new BuildServer(connection, projectId);
            var         artifact    = await buildHelper.AssociateArtifact(buildId, name, jobId, ArtifactResourceTypes.Container, fileContainerFullPath, propertiesDictionary, cancellationToken);

            context.Output(StringUtil.Loc("AssociateArtifactWithBuild", artifact.Id, buildId));
        }
コード例 #3
0
        public async Task UploadArtifactAsync(
            IExecutionContext context,
            IAsyncCommandContext commandContext,
            VssConnection connection,
            Guid projectId,
            string containerPath,
            string name,
            Dictionary <string, string> propertiesDictionary,
            string source,
            CancellationToken cancellationToken)
        {
            int?buildId = context.Variables.Build_BuildId;

            ArgUtil.NotNull(buildId, nameof(buildId));

            long?containerId = context.Variables.Build_ContainerId;

            ArgUtil.NotNull(containerId, nameof(containerId));

            context.Debug($"Upload artifact: {source} to server for build: {buildId.Value} at backend.");
            FileContainerServer fileContainerHelper = new FileContainerServer(connection, projectId, containerId.Value, containerPath);
            await fileContainerHelper.CopyToContainerAsync(commandContext, source, cancellationToken);

            string fileContainerFullPath = StringUtil.Format($"#/{containerId.Value}/{containerPath}");

            context.Output(StringUtil.Loc("UploadToFileContainer", source, fileContainerFullPath));

            BuildServer buildHelper = new BuildServer(connection, projectId);
            var         artifact    = await buildHelper.AssociateArtifact(buildId.Value, name, WellKnownArtifactResourceTypes.Container, fileContainerFullPath, propertiesDictionary, cancellationToken);

            context.Output(StringUtil.Loc("AssociateArtifactWithBuild", artifact.Id, buildId));
        }
コード例 #4
0
        private async Task AssociateArtifactAsync(
            IAsyncCommandContext context,
            VssConnection connection,
            Guid projectId,
            int buildId,
            string name,
            string type,
            string data,
            Dictionary <string, string> propertiesDictionary,
            CancellationToken cancellationToken)
        {
            BuildServer buildHelper = new BuildServer(connection, projectId);
            var         artifact    = await buildHelper.AssociateArtifact(buildId, name, type, data, propertiesDictionary, cancellationToken);

            context.Output(StringUtil.Loc("AssociateArtifactWithBuild", artifact.Id, buildId));
        }
コード例 #5
0
        public async Task AssociateArtifactAsync(
            IExecutionContext context,
            IAsyncCommandContext commandContext,
            VssConnection connection,
            Guid projectId,
            string name,
            string type,
            string data,
            Dictionary <string, string> propertiesDictionary,
            CancellationToken cancellationToken)
        {
            int?buildId = context.Variables.Build_BuildId;

            ArgUtil.NotNull(buildId, nameof(buildId));

            context.Debug($"Associate artifact: {name} with build: {buildId.Value} at backend.");
            BuildServer buildHelper = new BuildServer(connection, projectId);
            var         artifact    = await buildHelper.AssociateArtifact(buildId.Value, name, type, data, propertiesDictionary, cancellationToken);

            context.Output(StringUtil.Loc("AssociateArtifactWithBuild", artifact.Id, buildId));
        }
コード例 #6
0
        private async Task UploadArtifactAsync(
            IAsyncCommandContext context,
            Uri projectCollection,
            VssCredentials credentials,
            Guid projectId,
            long containerId,
            string containerPath,
            int buildId,
            string name,
            Dictionary<string, string> propertiesDictionary,
            string source,
            CancellationToken cancellationToken)
        {
            FileContainerServer fileContainerHelper = new FileContainerServer(projectCollection, credentials, projectId, containerId, containerPath);
            await fileContainerHelper.CopyToContainerAsync(context, source, cancellationToken);
            string fileContainerFullPath = StringUtil.Format($"#/{containerId}/{containerPath}");
            context.Output(StringUtil.Loc("UploadToFileContainer", source, fileContainerFullPath));

            BuildServer buildHelper = new BuildServer(projectCollection, credentials, projectId);
            var artifact = await buildHelper.AssociateArtifact(buildId, name, WellKnownArtifactResourceTypes.Container, fileContainerFullPath, propertiesDictionary, cancellationToken);
            context.Output(StringUtil.Loc("AssociateArtifactWithBuild", artifact.Id, buildId));
        }
コード例 #7
0
 private async Task AssociateArtifactAsync(
     IAsyncCommandContext context,
     Uri projectCollection,
     VssCredentials credentials,
     Guid projectId,
     int buildId,
     string name,
     string type,
     string data,
     Dictionary<string, string> propertiesDictionary,
     CancellationToken cancellationToken)
 {
     BuildServer buildHelper = new BuildServer(projectCollection, credentials, projectId);
     var artifact = await buildHelper.AssociateArtifact(buildId, name, type, data, propertiesDictionary, cancellationToken);
     context.Output(StringUtil.Loc("AssociateArtifactWithBuild", artifact.Id, buildId));
 }