コード例 #1
0
ファイル: GetCommand.cs プロジェクト: frandi/OpenCatapult
        public override string Execute()
        {
            Console.WriteLine($"Trying to get task {Name} in job definition {Job}...");

            string message;

            var project = _projectService.GetProjectByName(Project).Result;

            if (project != null)
            {
                var job = _jobDefinitionService.GetJobDefinitionByName(project.Id, Job).Result;

                if (job != null)
                {
                    var task = _jobDefinitionService.GetJobTaskDefinitionByName(project.Id, job.Id, Name).Result;

                    if (task != null)
                    {
                        var configs       = _pluginService.GetProviderAdditionalConfigByProviderName(task.Provider).Result;
                        var secretConfigs = configs.Where(c => c.IsSecret).Select(c => c.Name).ToArray();
                        message = task.ToCliString($"Task {Name} in job {Job}:", secretConfigs, excludedFields: new string[]
                        {
                            "JobDefinitionId"
                        });
                        return(message);
                    }
                }
            }

            message = $"Failed to fetch task {Name}. Make sure the project, job definition, and task names are correct.";

            return(message);
        }
コード例 #2
0
        public async Task <IActionResult> GetJobTaskDefinition(int projectId, int jobId, string taskName)
        {
            _logger.LogInformation("Getting job task definition {taskName} in job definition {jobId}, project {projectId}", taskName, jobId, projectId);

            var jobTaskDefinition = await _jobDefinitionService.GetJobTaskDefinitionByName(jobId, taskName);

            var result = _mapper.Map <JobTaskDefinitionDto>(jobTaskDefinition);

            return(Ok(result));
        }
コード例 #3
0
        public async Task <IActionResult> GetJobTaskDefinition(int projectId, int jobId, string taskName)
        {
            _logger.LogRequest("Getting job task definition {taskName} in job definition {jobId}, project {projectId}", taskName, jobId, projectId);

            var jobTaskDefinition = await _jobDefinitionService.GetJobTaskDefinitionByName(jobId, taskName);

            var result = _mapper.Map <JobTaskDefinitionDto>(jobTaskDefinition);

            _logger.LogResponse("Job task definition {taskName} in job {jobId} in project {projectId} retrieved. Response body: {@result}", taskName, jobId, projectId, result);

            return(Ok(result));
        }
コード例 #4
0
        public override string Execute()
        {
            if (!(AutoConfirm || Console.GetYesNo($"Are you sure you want to remove task {Name} from job definition {Job}?", false)))
            {
                return(string.Empty);
            }

            Console.WriteLine($"Trying to remove task \"{Name}\" from job definition {Job}...");

            string message;

            var project = _projectService.GetProjectByName(Project).Result;

            if (project != null)
            {
                var job = _jobDefinitionService.GetJobDefinitionByName(project.Id, Job).Result;

                if (job != null)
                {
                    var task = _jobDefinitionService.GetJobTaskDefinitionByName(project.Id, job.Id, Name).Result;

                    if (task != null)
                    {
                        _jobDefinitionService.DeleteJobTaskDefinition(project.Id, job.Id, task.Id).Wait();

                        message = $"Task {Name} has been removed successfully";
                        Logger.LogInformation(message);
                        return(message);
                    }
                }
            }

            message = $"Failed to remove task {Name}. Make sure the project, job definition, and task names are correct.";

            return(message);
        }