예제 #1
0
        public JobExecutionResult[] ExecuteAllJobs()
        {
            var results = new JobExecutionResult[Jobs.Length];

            for (var i = 0; i < Jobs.Length; i++)
            {
                var job = Jobs[i];

                results[i] = ExecuteJob(job);

                // if success, or job is on the allowed failures matrix, continue on to next one
                if (results[i].IsSuccessfulExecution ||
                    buildConfiguration.Matrix.AllowedFailures.Any(a => a.AreConditionsMetForJob(job)))
                {
                    continue;
                }

                // if fast_finish is on mark remaining jobs as NotExecuted and leave build
                if (buildConfiguration.Matrix.IsFastFinish)
                {
                    for (++i; i < Jobs.Length; i++)
                    {
                        results[i] = JobExecutionResult.CreateNotExecuted();
                    }

                    break;
                }
            }

            return(results);
        }
예제 #2
0
        public JobExecutionResult ExecuteJob(int jobIndex)
        {
            if (jobIndex < 0 || jobIndex >= Jobs.Length)
            {
                var result = JobExecutionResult.CreateJobNotFound();
                JobEnded?.Invoke(this, new JobEndedEventArgs(null, result));
                return(result);
            }

            return(ExecuteJob(Jobs[jobIndex]));
        }
예제 #3
0
        public JobExecutionResult ExecuteJob(MatrixJob job)
        {
            JobStarting?.Invoke(this, new JobStartingEventArgs(job));

            var executionContext = new ExecutionContext(
                job,
                buildConfiguration,
                engineConfiguration.Outputter,
                engineConfiguration.RepositoryDirectoryPath,
                !string.IsNullOrEmpty(buildConfiguration.CloneFolder)
                    ? buildConfiguration.CloneFolder
                    : new ExpandableString(@"C:\Projects\LocalAppVeyorTempClone"));

            JobExecutionResult executionResult;

            try
            {
                var isSuccess = ExecuteBuildPipeline(executionContext);

                // on_success / on_failure only happen here, after we know the build status
                // they do intervene on build final status though
                isSuccess = isSuccess
                    ? new OnSuccessStep(engineConfiguration.FileSystem, executionContext.CloneDirectory, buildConfiguration.OnSuccessScript).Execute(executionContext)
                    : new OnFailureStep(engineConfiguration.FileSystem, executionContext.CloneDirectory, buildConfiguration.OnFailureScript).Execute(executionContext);

                return(isSuccess
                    ? JobExecutionResult.CreateSuccess()
                    : JobExecutionResult.CreateFailure());
            }
            catch (SolutionNotFoundException)
            {
                executionResult = JobExecutionResult.CreateSolutionNotFound();
            }
            catch (Exception e)
            {
                executionResult = JobExecutionResult.CreateUnhandledException(e);
            }
            finally
            {
                // on_finish don't influence build final status so we just run it
                new OnFinishStep(engineConfiguration.FileSystem, executionContext.CloneDirectory, buildConfiguration.OnFinishScript).Execute(executionContext);
            }

            JobEnded?.Invoke(this, new JobEndedEventArgs(job, executionResult));

            return(executionResult);
        }
예제 #4
0
 public JobEndedEventArgs(MatrixJob job, JobExecutionResult executionResult)
 {
     Job             = job;
     ExecutionResult = executionResult;
 }