/// <summary> /// Determine if this <see cref="BuildPipeline"/> can run. /// </summary> /// <param name="config">The <see cref="BuildConfiguration"/> used for the build.</param> /// <param name="reason">If <see cref="CanRun"/> returns <see langword="false"/>, the reason why it fails.</param> /// <returns>The result of running this <see cref="BuildPipeline"/>.</returns> public bool CanRun(BuildConfiguration config, out string reason) { var result = BuildArtifacts.GetBuildResult(config); if (result == null) { reason = $"No build result found for {config.name.ToHyperLink()}."; return(false); } if (result.Failed) { reason = $"Last build failed with error:\n{result.Message}"; return(false); } if (RunStep == null) { reason = $"No run step provided for {name.ToHyperLink()}."; return(false); } if (!RunStep.CanRun(config, out reason)) { return(false); } reason = null; return(true); }
BoolResult CanRun(RunContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var result = BuildArtifacts.GetBuildResult(context.BuildConfiguration); if (result == null) { return(BoolResult.False($"No build result found for {context.BuildConfiguration.ToHyperLink()}.")); } if (result.Failed) { return(BoolResult.False($"Last build failed with error:\n{result.Message}")); } return(OnCanRun(context)); }
/// <summary> /// Get the last build result for this build configuration. /// </summary> /// <param name="config">The build configuration that was used to store the build artifact.</param> /// <returns>The build result if found, otherwise <see langword="null"/>.</returns> public BuildPipelineResult GetLastBuildResult() => BuildArtifacts.GetBuildResult(this);