public void Run(CancellationToken taskCancelToken, LoggerList loggers) { //Create Build Object Build build = CreateBuild(); //Create Job Build logger JobBuildLogger buildLogger = new JobBuildLogger(Name, build.Number); loggers.AddLogger(buildLogger); //Start Execution buildLogger.Log(new Log("Start at " + DateTime.Now + "\n")); FailedBuildTokenSource failedTokenSource = new FailedBuildTokenSource(); try { //Create the build Environment Class.Environment env = new Class.Environment(); foreach (Property prop in Properties) { prop.Definition.Apply(env, prop.Parameters.ToArray(), failedTokenSource, loggers); CheckIfBuildCanceled(taskCancelToken, build, buildLogger); failedTokenSource.Token.ThrowIfFailed(); } env.Properties.Add("buildNumber", build.Number.ToString()); PreBuild(build, env, taskCancelToken, failedTokenSource, loggers); Build(build, env, taskCancelToken, failedTokenSource, loggers); AfterBuild(build, env, taskCancelToken, failedTokenSource, loggers); buildLogger.Log(new Log("\nBUILD SUCCESS")); buildLogger.Log(new Log("\nEnd at " + DateTime.Now)); build.Status = "SUCCESS"; } catch (OperationCanceledException e) { throw e; } catch (FailedBuildException e) { build.Status = "FAILED"; buildLogger.Log(new Log("BUILD FAILED")); buildLogger.Log(new Log("\nEnd at " + DateTime.Now)); } }
public void RunJob(JobRunModel model) { //Instanciate plugins depending on class name Job job = PluginStorage.CreateObject <Job>( //Go Fetch class name from config file JObject.Parse(File.ReadAllText("jobs\\" + model.Name + "\\config.json")).Value <string>("_class") ); //Load job from folder configuration job.LoadFromFolder("jobs", model.Name); //Create Logger list for the run LoggerList loggers = new LoggerList(); //Add Standard logger in the logger list loggers.AddLogger(new StandardLogger()); //Add job build in the process with his name as key and provide log _threadApplication.AddRun(model.Name, job, loggers); }