/// <inheritdoc/> public Task Perform(IPerformerLog log, Context score) { log.Information($"Get latest source into '{score.SourcePath}'"); var gitFolder = Path.Combine(score.SourcePath, ".git"); if (!Directory.Exists(gitFolder)) { Clone(log, score); } else { try { Pull(log, score); } catch { log.Information("Problems pulling - recreating"); Directory.Delete(score.SourcePath, true); Clone(log, score); } } return(Task.CompletedTask); }
public override Task Perform(IPerformerLog log, score_context score) { return(Task.Run(() => { Task.Delay(500); last_performer = "first"; })); }
/// <inheritdoc/> public async Task Perform(IPerformerLog log, Context score) { var client = new HttpClient(); var messageCard = new MessageCard { title = "Dolittle Build", summary = "Build", /* * sections = new Section[] { * new Activity { * activityTitle = "Blah blah blah", * activityText= "[Build .NET Fundamentals...]" * }, * new Facts { * title = "Details", * facts = new[] { * new Fact { name = "Commit", value= "[Blah blah]"}, * new Fact { name = "Message", value= "[Blah blah]"}, * new Fact { name = "Duration", value= "[Blah blah]"} * } * * } * }, */ /* * potentialAction = new[] { * new ActionCard { * name = "Send feedback", * inputs = new [] { * new TextInput { * id = "feedback", * title = "Lets get rumbling..." * } * }, * actions = new [] { * new HttpPOST { * name = "Send feedback", * target = "http://www.vg.no" * } * } * } * }*/ }; var json = _serializer.ToJson(messageCard); var jsonAsBytes = Encoding.UTF8.GetBytes(json); var content = new ByteArrayContent(jsonAsBytes); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var response = await client.PostAsync("https://outlook.office.com/webhook/637a02ae-0097-437e-b9b6-a20b2f8731a8@381088c1-de08-4d18-9e60-bbe2c94eccb5/IncomingWebhook/c6cb4389c11b4f77a75580f88a5fc1f6/3ddacd79-85b8-4357-915d-530e1d2b3e0a", content); var responseContent = await response.Content.ReadAsStringAsync(); }
/// <inheritdoc/> public Task Perform(IPerformerLog log, Context score) { log.Information("Getting version"); using (var repo = new Repository(score.SourcePath)) { var tag = repo.Tags.ToArray().LastOrDefault(); if (tag != null) { score.Version = $"{tag.FriendlyName}.{score.BuildNumber}"; } log.Information($"Version is {score.Version}"); } return(Task.CompletedTask); }
void Clone(IPerformerLog log, Context score) { log.Information("Cloning"); var cloneOptions = new CloneOptions(); cloneOptions.RecurseSubmodules = true; cloneOptions.OnCheckoutProgress = (string path, int completedSteps, int totalSteps) => log.Information(path); /* * cloneOptions.CredentialsProvider = (_url, _user, _cred) => * new UsernamePasswordCredentials * { * Username = "******", * Password = "******" * }; */ //if( Directory.Exists(score.SourcePath) ) Directory.Delete(score.SourcePath); Repository.Clone(score.Project.Repository.ToString(), score.SourcePath, cloneOptions); }
void Pull(IPerformerLog log, Context score) { log.Information("Repository already exists - pulling latest"); using (var repo = new Repository(score.SourcePath)) { var pullOptions = new PullOptions(); pullOptions.FetchOptions = new FetchOptions(); var signature = new Signature( new Identity("<Dolittle CI>", "*****@*****.**"), DateTimeOffset.Now); pullOptions.FetchOptions.Prune = true; pullOptions.FetchOptions.TagFetchMode = TagFetchMode.All; pullOptions.FetchOptions.OnProgress = (string message) => { log.Information(message); return(true); }; Commands.Pull(repo, signature, pullOptions); } }
/// <inheritdoc/> public async Task Perform(IPerformerLog log, Context score) { var settings = new Settings("./"); var packageSourceProvider = new PackageSourceProvider(settings); var repositoriesToPushTo = Config.Repositories.Where(_ => _.CanPush(score)); Parallel.ForEach(repositoriesToPushTo, async _ => { try { await global::NuGet.Commands.PushRunner.Run( settings, packageSourceProvider, "path", "source", "apiKey", "symbolSource", "symbolApiKey", 3600, // Timeout false, // Disable buffering false, // NoSymbols false, // No Service Endpoint new NuGetLogger()); } catch (TaskCanceledException) { // Timeout } catch (Exception) { throw; } }); await Task.CompletedTask; }
public Task Perform(IPerformerLog log, score_context score) { return(Task.CompletedTask); }
async Task StartJobFor(IPerformerLog log, Context context, Read.Configuration.Build build) { var @namespace = "dolittle"; var metadata = new V1ObjectMeta { Name = Guid.NewGuid().ToString() //, //Labels = { { "type", "build" } } }; log.Information($"---"); log.Information($"Type : {build.Type}"); log.Information($"BasePath : {build.BasePath}"); log.Information($"Package : {build.Package}"); log.Information($"Publish : {build.Publish}"); log.Information($"Folder with project to publish : {build.FolderWithProjectToPublish}"); log.Information($"---"); var job = new V1Job { Metadata = metadata, Spec = new V1JobSpec { Completions = 1, Template = new V1PodTemplateSpec { Metadata = metadata, Spec = new V1PodSpec { Containers = new [] { new V1Container { Name = "build", Image = $"dolittlebuild/{build.Type}", ImagePullPolicy = "Always", Env = new [] { new V1EnvVar("REPOSITORY", context.Project.Repository.ToString()), new V1EnvVar("COMMIT", context.SourceControl.Commit), new V1EnvVar("PULL_REQUEST", context.IsPullRequest.ToString()), new V1EnvVar("VERSION", context.Version), new V1EnvVar("BASE_PATH", build.BasePath), new V1EnvVar("PACKAGE", build.Package.ToString()), new V1EnvVar("PUBLISH", build.Publish.ToString()), new V1EnvVar("FOLDER_WITH_PROJECT_TO_PUBLISH", build.FolderWithProjectToPublish), new V1EnvVar("CALLBACK", $"http://continuousimprovement/buildJobDone?jobName={metadata.Name}") }, VolumeMounts = new[] { new V1VolumeMount { Name = "azure", MountPath = "/repository", SubPath = context.Volumes.SourcePath }, new V1VolumeMount { Name = "azure", MountPath = "/packages", SubPath = context.Volumes.PackagePath }, new V1VolumeMount { Name = "azure", MountPath = "/output", SubPath = context.Volumes.OutputPath }, new V1VolumeMount { Name = "azure", MountPath = "/publish", SubPath = context.Volumes.PublishPath }, new V1VolumeMount { Name = "azure", MountPath = "/testresults", SubPath = context.Volumes.TestResultsPath } } } }, Volumes = new[] { new V1Volume { Name = "azure", AzureFile = new V1AzureFileVolumeSource { SecretName = "azure-storage-secret", ShareName = "continuousimprovement", ReadOnlyProperty = false } } }, RestartPolicy = "Never", } } } }; await _kubernetes.CreateNamespacedJobAsync(job, @namespace); }
/// <inheritdoc/> public Task Perform(IPerformerLog log, Context context) { log.Information("Building jobs"); context.Project.Builds.ForEach(async _ => await StartJobFor(log, context, _)); return(Task.CompletedTask); }
public override Task Perform(IPerformerLog log, score_context score) { last_performer = "second"; return(Task.CompletedTask); }
public virtual Task Perform(IPerformerLog log, score_context score) { perform_called = true; perform_score = score; return(Task.CompletedTask); }