/// <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 timer = Stopwatch.StartNew(); result = OnRun(context); timer.Stop(); if (result != null) { result.Duration = timer.Elapsed; } } } catch (Exception exception) { result = RunResult.Failure(this, config, exception); } return(result); }
/// <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);
/// <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);