Example #1
0
 public static void MarkJobAsCompleteWithError(Job job)
 {
     using (var repo = new JobRepository())
     {
         repo.UpdateStateForJob(job, JobState.CompletedWithError);
     }
 }
Example #2
0
 public static void MarkJobAsFailed(Job job, string error)
 {
     using (var repo = new JobRepository())
     {
         repo.UpdateStateForJob(job, JobState.Failed, error);
     }
 }
Example #3
0
        public static Job GetJob(int jobId, Logger defaultLogger)
        {
            Job currentJob;
            using (var repo = new JobRepository())
            {
                defaultLogger.Info("Passed job with ID of {0}", jobId);

                currentJob = repo.GetJobById(jobId);

                if (currentJob == null)
                {
                    defaultLogger.Warn("Job not found");
                    return null;
                }

                defaultLogger.Info("Job found. URL is {0} and branch is {1}", currentJob.Url, currentJob.Branch);

                if (currentJob.State != JobState.Pending)
                {
                    defaultLogger.Warn("Cannot start job. Current state is {0}", currentJob.State);
                    return null;
                }

                repo.UpdateStateForJob(currentJob, JobState.Running);
            }

            return currentJob;
        }