private async Task <JobExecutionsListingResult> GetExecutions(JobImportResult jobImportResult) { JobExecutionsListingResult executionResult; while (true) { executionResult = await RundeckClient .Jobs .GetExecutionsAsync(jobImportResult.Id) .ConfigureAwait(false); // if there are no Executions or the Job is still running, try agin // Todo - this loop never finishes if something goes wrong with running the Job if (executionResult.Executions.Count == 0 || executionResult.Executions.Any(e => e.Status == JobExecutionStatus.Running)) { await Task.Delay(100).ConfigureAwait(false); continue; } break; } return(executionResult); }
private async Task RunJobAsync(JobImportResult jobImportResult) { // Enable execution on the Job and then run it await RundeckClient .Jobs .EnableExecutionsAsync(jobImportResult.Id) .ConfigureAwait(false); await RundeckClient .Jobs .ExecuteAsync(jobImportResult.Id) .ConfigureAwait(false); }