Cake.Frosting: How to run a task even though a previous task failed? #3809
-
|
Hello, I've migrated our cake script to cake frosting and merged some of the azure pipelines into the cake pipeline. My tasks are structured roughly: Thanks in advance |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
|
@StefanOssendorf kind of. You can override As an example: using System;
using Cake.Common.Diagnostics;
using Cake.Core;
using Cake.Frosting;
public static class Program
{
public static int Main(string[] args)
{
return new CakeHost()
.Run(args);
}
}
[TaskName("WillFail")]
public sealed class WillFailTask : FrostingTask
{
public override void Run(ICakeContext context)
{
throw new Exception("Boom!");
}
public override void OnError(Exception exception, ICakeContext context)
{
context.Information($"Well, well, an error of {exception.GetType().Name} occured.");
}
}
[TaskName("Default")]
[IsDependentOn(typeof(WillFailTask))]
public class DefaultTask : FrostingTask
{
public override void Run(ICakeContext context)
{
context.Information("Hello, from Default!");
}
} |
Beta Was this translation helpful? Give feedback.
@StefanOssendorf kind of. You can override
OnErrorin the task that fails (not the following) and make Cake not abort the build on that error.As an example: