protected override async Task <int> DoExecuteAsync(ITaskContextInternal context)
        {
            var client = WebApiClientFactory.Create(context.Properties.Get <string>(BuildProps.LastWebApiBaseUrl));

            try
            {
                var response = await client.ExecuteScriptAsync(new ExecuteScriptRequest
                {
                    ScriptFileName  = _scriptFilePath,
                    TargetToExecute = _mainCommand,
                    ScriptArguments = _scriptArguments,
                });

#if !NETSTANDARD1_6
                WriteLogs(response.Logs, _logsForegroundColor);
#else
                WriteLogs(response.Logs);
#endif
            }
            catch (WebApiException e)
            {
#if !NETSTANDARD1_6
                WriteLogs(e.Logs, _logsForegroundColor);
 #else
                WriteLogs(e.Logs);
#endif

                throw new TaskExecutionException("Execute script failed!", 99);
            }

            return(0);
        }
        protected override async Task <int> DoExecuteAsync(ITaskContextInternal context)
        {
            var client   = WebApiClientFactory.Create(context.Properties.Get <string>(BuildProps.LastWebApiBaseUrl));
            var response = await client.ExecuteAsync(c => c.UploadPackageAsync(new UploadPackageRequest
            {
                PackageSearchPattern = _packageSearchPattern,
                DirectoryPath        = _directoryPath,
                UploadToSubDirectory = _uploadToSubDirectory,
            }));

            if (response.Error != null)
            {
                throw new TaskExecutionException($"Upload packages failed: ErrorCode: {response.Error.ErrorCode} ErrorMessage: {response.Error.ErrorMessage}", 99);
            }

            if (response.Data == null || response.Data.Count == 0)
            {
                context.LogInfo("No packages uploaded.");
            }
            else
            {
                foreach (var package in response.Data)
                {
                    context.LogInfo($"Uploaded: {package}");
                }
            }

            return(0);
        }
示例#3
0
        protected override async Task <int> DoExecuteAsync(ITaskContextInternal context)
        {
            var client = WebApiClientFactory.Create(context.Properties.Get <string>(BuildProps.LastWebApiBaseUrl));
            await client.UploadScriptAsync(new UploadScriptRequest
            {
                FilePath = _scriptFilePath
            });

            return(0);
        }
示例#4
0
        protected override async Task <int> DoExecuteAsync(ITaskContextInternal context)
        {
            var client = WebApiClientFactory.Create(context.Properties.Get <string>(BuildProps.LastWebApiBaseUrl));
            await client.UploadPackageAsync(new UploadPackageRequest
            {
                PackageSearchPattern = _packageSearchPattern,
                DirectoryPath        = _directoryPath,
                UploadToSubDirectory = _uploadToSubDirectory,
            });

            return(0);
        }
示例#5
0
        protected override async Task <int> DoExecuteAsync(ITaskContextInternal context)
        {
            var client = WebApiClientFactory.Create(context.Properties.Get <string>(BuildProps.LastWebApiBaseUrl));
            await client.ExecuteScriptAsync(new ExecuteScriptRequest
            {
                ScriptFileName    = _scriptFilePath,
                TargetToExecute   = _mainCommand,
                RemainingCommands = _commands,
            });

            return(0);
        }
示例#6
0
        protected override async Task <int> DoExecuteAsync(ITaskContextInternal context)
        {
            var client   = WebApiClientFactory.Create(context.Properties.Get <string>(BuildProps.LastWebApiBaseUrl));
            var response = await client.ExecuteAsync(c => c.UploadScriptAsync(new UploadScriptRequest
            {
                FilePath = _scriptFilePath
            }));

            if (response != null)
            {
                throw new TaskExecutionException($"Upload script failed: ErrorCode: {response.ErrorCode} ErrorMessage: {response.ErrorMessage}", 99);
            }

            return(0);
        }
        protected override async Task <int> DoExecuteAsync(ITaskContextInternal context)
        {
            if (string.IsNullOrEmpty(_saveAs))
            {
                throw new ArgumentNullException(nameof(_saveAs));
            }

            var extension = Path.GetExtension(_saveAs);

            if (string.IsNullOrEmpty(extension) || !extension.Equals(".zip", StringComparison.OrdinalIgnoreCase))
            {
                throw new TaskExecutionException("SaveAs file extension must be .zip", 99);
            }

            var client = WebApiClientFactory.Create(context.Properties.Get <string>(BuildProps.LastWebApiBaseUrl));

            try
            {
                var reports = await client.DownloadReportsAsync(new DownloadReportsRequest()
                {
                    DownloadFromSubDirectory = _subDirectory
                }) as MemoryStream;

                using (FileStream file = new FileStream(_saveAs, FileMode.Create, FileAccess.Write))
                {
                    reports.WriteTo(file);

#if !NETSTANDARD1_6
                    reports.Close();
                    file.Close();
#endif
                }
            }
            catch (WebApiException e)
            {
                if (e.ErrorCode == "NoReportsFound" && !_failWhenNoReportsFound)
                {
                    context.LogInfo("No reports found on server.");
                    return(0);
                }

                throw;
            }

            return(0);
        }
示例#8
0
        protected override async Task <int> DoExecuteAsync(ITaskContextInternal context)
        {
            var client = WebApiClientFactory.Create(context.Properties.Get <string>(BuildProps.LastWebApiBaseUrl));

            try
            {
                var response = await client.ExecuteScriptAsync(new ExecuteScriptRequest
                {
                    ScriptFileName  = _scriptFilePath,
                    TargetToExecute = _mainCommand,
                    ScriptArguments = _scriptArguments,
                });

                WriteLogs(response.Logs);
            }
            catch (WebApiException e)
            {
                WriteLogs(e.Logs);
                throw;
            }

            return(0);
        }