Beispiel #1
0
        /// <summary>
        /// Run the last build of this build pipeline corresponding to the specified build configuration.
        /// </summary>
        /// <param name="config">The build configuration corresponding to the build to be run.</param>
        /// <param name="runTargets">List of devices to deploy and run on.</param>
        /// <returns>A result describing if run is successful or not.</returns>
        public RunResult Run(BuildConfiguration config, params RunTargetBase[] runTargets)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            RunResult result = null;

            try
            {
                using (var context = new RunContext(this, config, runTargets))
                {
                    var canRun = CanRun(context);
                    if (!canRun.Result)
                    {
                        return(RunResult.Failure(this, config, canRun.Reason));
                    }

                    var startTime = DateTime.Now;
                    var timer     = Stopwatch.StartNew();
                    result = OnRun(context);
                    timer.Stop();

                    if (result != null)
                    {
                        result.StartTime = startTime;
                        result.Duration  = timer.Elapsed;
                    }
                }
            }
            catch (Exception exception)
            {
                result = RunResult.Failure(this, config, exception);
            }
            return(result);
        }
Beispiel #2
0
 /// <summary>
 /// Get a run result representing a failure.
 /// </summary>
 /// <param name="exception">The exception that was thrown.</param>
 /// <returns>A new run result instance.</returns>
 public RunResult Failure(Exception exception) => RunResult.Failure(BuildPipeline, BuildConfiguration, exception);
Beispiel #3
0
 /// <summary>
 /// Get a run result representing a failure.
 /// </summary>
 /// <param name="reason">The reason of the failure.</param>
 /// <returns>A new run result instance.</returns>
 public RunResult Failure(string reason) => RunResult.Failure(BuildPipeline, BuildConfiguration, reason);
Beispiel #4
0
 /// <summary>
 /// Get a run result representing a success.
 /// </summary>
 /// <param name="instance">The run process instance.</param>
 /// <returns>A new run result instance.</returns>
 public RunResult Success(IRunInstance instance = null) => RunResult.Success(BuildPipeline, BuildConfiguration, instance);