public override string Execute() { Console.WriteLine($"Trying to update job definition \"{Name}\" from project {Project}..."); string message; var project = _projectService.GetProjectByName(Project).Result; if (project != null) { var job = _jobDefinitionService.GetJobDefinitionByName(project.Id, Name).Result; if (job != null) { _jobDefinitionService.UpdateJobDefinition(project.Id, job.Id, new UpdateJobDefinitionDto { Id = job.Id, Name = Rename ?? job.Name }).Wait(); message = $"Job definition {Name} has been updated successfully"; Logger.LogInformation(message); return(message); } } message = $"Failed to update job definition {Name}. Make sure the project and job definition names are correct."; return(message); }
public override string Execute() { if (!(AutoConfirm || Console.GetYesNo($"Are you sure you want to remove job {Name} from project {Project}?", false))) { return(string.Empty); } Console.WriteLine($"Trying to remove job definition \"{Name}\" from project {Project}..."); string message; var project = _projectService.GetProjectByName(Project).Result; if (project != null) { var job = _jobDefinitionService.GetJobDefinitionByName(project.Id, Name).Result; if (job != null) { _jobDefinitionService.DeleteJobDefinition(project.Id, job.Id).Wait(); message = $"Job definition {Name} has been removed successfully"; Logger.LogInformation(message); return(message); } } message = $"Failed to remove job definition {Name}. Make sure the project and job definition names are correct."; return(message); }
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); }
public override string Execute() { Console.WriteLine($"Trying to set job definition \"{Name}\" from project {Project} as default..."); string message; var project = _projectService.GetProjectByName(Project).Result; if (project != null) { var job = _jobDefinitionService.GetJobDefinitionByName(project.Id, Name).Result; if (job != null) { _jobDefinitionService.SetJobDefinitionAsDefault(project.Id, job.Id).Wait(); message = $"Job definition {Name} has been set to default"; Logger.LogInformation(message); return(message); } } message = $"Failed to set job definition {Name} as default. Make sure the project and job definition names are correct."; return(message); }
public async Task <IActionResult> GetJobDefinition(int projectId, string jobName) { _logger.LogInformation("Getting job definition {jobName} in project {projectId}", jobName, projectId); var jobDefinition = await _jobDefinitionService.GetJobDefinitionByName(projectId, jobName); var result = _mapper.Map <JobDefinitionDto>(jobDefinition); return(Ok(result)); }
public async Task <IActionResult> GetJobDefinition(int projectId, string jobName) { _logger.LogRequest("Getting job definition {jobName} in project {projectId}", jobName, projectId); var jobDefinition = await _jobDefinitionService.GetJobDefinitionByName(projectId, jobName); var result = _mapper.Map <JobDefinitionDto>(jobDefinition); _logger.LogResponse("Job definition {jobName} in project {projectId} retrieved. Reponse body: {@result}", jobName, projectId, result); return(Ok(result)); }
public override string Execute() { Console.WriteLine($"Trying to queue job \"{Job}\" in project {Project}..."); string message; var project = _projectService.GetProjectByName(Project).Result; if (project != null) { var job = _jobDefinitionService.GetJobDefinitionByName(project.Id, Job).Result; if (job != null) { var queue = _jobQueueService.CreateJobQueue(project.Id, new NewJobDto { ProjectId = project.Id, JobDefinitionId = job.Id, OriginUrl = Dns.GetHostEntry(Dns.GetHostName()).AddressList.Last(a => a.AddressFamily == AddressFamily.InterNetwork).ToString() }).Result; message = queue.ToCliString($"Job {Job} has been queued successfully:", excludedFields: new string[] { "ProjectId", "JobDefinitionId", "JobTasksStatus", "OutputValues", "CatapultEngineId", "CatapultEngineMachineName", "CatapultEngineIPAddress", "CatapultEngineVersion" }); Logger.LogInformation(message); message += "\nThe job will be picked up by a running engine shortly."; return(message); } } message = $"Failed to queue job {Job}. Make sure the project and job definition names are correct."; return(message); }
public override string Execute() { Console.WriteLine($"Trying to get job definition {Name} in project {Project}..."); string message; var project = _projectService.GetProjectByName(Project).Result; if (project != null) { var job = _jobDefinitionService.GetJobDefinitionByName(project.Id, Name).Result; if (job != null) { var secretConfig = new List <string>(); if (job.Tasks?.Count > 0) { foreach (var task in job.Tasks) { var configs = _pluginService.GetProviderAdditionalConfigByProviderName(task.Provider).Result; secretConfig.AddRange(configs.Where(c => c.IsSecret).Select(c => c.Name)); } } message = job.ToCliString($"Job definition {Name}", secretConfig.ToArray(), excludedFields: new string[] { "ProjectId", "JobDefinitionId" }); return(message); } } message = $"Failed to get job definition {Name}. Make sure the project and job definition names are correct."; return(message); }
public override string Execute() { Console.WriteLine($"Trying to get tasks for 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 tasks = _jobDefinitionService.GetJobTaskDefinitions(project.Id, job.Id).Result; var secretConfig = new List <string>(); foreach (var task in tasks) { var configs = _pluginService.GetProviderAdditionalConfigByProviderName(task.Provider).Result; secretConfig.AddRange(configs.Where(c => c.IsSecret).Select(c => c.Name)); } message = tasks.ToListCliString($"Found {tasks.Count} task(s):", secretConfig.ToArray(), excludedFields: new string[] { "JobDefinitionId", "Configs", "AdditionalConfigs" }); return(message); } } message = $"Failed to fetch tasks. Make sure the project and job names are correct."; return(message); }