Beispiel #1
0
        public override async Task Execute(DeploymentManifestSourceTrackingContext context)
        {
            using (_log.BeginScope(new Dictionary <string, object>
            {
                { "Application", context.ApplicationName },
                { "Ref", context.DeploymentManifest.Repository.Ref },
                { "Path", context.DeploymentManifest.Path }
            }))
            {
                var repository = context.DeploymentManifest.Repository;
                await _deploymentManifestRepositoryService.Checkout(repository);

                var application = _applicationService.GetApplication(context.ApplicationName);

                var manifestsChanged = context.DeploymentManifest switch
                {
                    HelmDeploymentManifest helmDeploymentManifest => await InternalExecute(helmDeploymentManifest,
                                                                                           application),
                    RawDeploymentManifest rawDeploymentManifest => await InternalExecute(rawDeploymentManifest,
                                                                                         application),
                    _ => throw new ArgumentOutOfRangeException()
                };

                if (
                    manifestsChanged &&
                    context.AutoDeploy &&
                    !_configuration.Value.Dryrun)
                {
                    await _deploymentManifestRepositoryService.Push(repository);
                }
            }
        }
    }
Beispiel #2
0
        public override async Task Execute(DeploymentManifestSourceTrackingContext context)
        {
            var repository = context.DeploymentManifest.Repository;

            _log.LogInformation("Checkout repository containing application declaration");
            await _deploymentManifestRepositoryService.Checkout(repository, true);

            _log.LogInformation("Starting sync-job for {Repository} in {Path}",
                                repository.Uri,
                                repository.GetCheckoutDirectory()
                                );

            var job = JobFactory.BuildJobWithData <GitRepositorySyncJob, DeploymentManifestSourceTrackingContext>(
                $"gitwatch-{context.ApplicationName}",
                Constants.SchedulerGroup,
                context
                );

            var trigger = TriggerBuilder.Create()
                          .WithIdentity($"gitwatch-trig-{context.ApplicationName}", Constants.SchedulerGroup)
                          .StartNow()
                          .WithSimpleSchedule(x => x
                                              .WithIntervalInSeconds(10)
                                              .RepeatForever()
                                              )
                          .ForJob(job)
                          .Build();

            await _scheduler.ScheduleJob(job, trigger);
        }