Ejemplo n.º 1
0
 public async Task Validate()
 {
     if (this.Deployment.Status == DeploymentStatus.Running)
     {
         DeploymentEvent?.Invoke(this.Deployment, new ProgressEventArgs(new InvalidOperationException("Validation is already running.")));
     }
     else
     {
         await new TakoDeploy(this.Deployment).ValidateDeploy(e => DeploymentEvent?.Invoke(this, e));
     }
 }
Ejemplo n.º 2
0
 public async Task Deploy()
 {
     if (this.Deployment.Status == DeploymentStatus.Running)
     {
         DeploymentEvent?.Invoke(this.Deployment, new ProgressEventArgs(new InvalidOperationException("Deployment is already running.")));
     }
     else
     {
         TakoDeploy = new TakoDeploy(this.Deployment);
         await TakoDeploy.BeginDeploy(e => DeploymentEvent?.Invoke(this, e));
     }
 }
        protected override void OnRaiseDeploymentEvent(DeploymentEvent deploymentEvent)
        {
            if (deploymentEvent.Context == null)
            {
                deploymentEvent.Context = this;
            }

            lock (_eventsLock)
            {
                foreach (var eventHandler in _eventHandlers)
                {
                    deploymentEvent.HandleEvent(eventHandler);
                }
            }
        }
Ejemplo n.º 4
0
        public int RecordTriggered(string buildNumber, string teamProject, string teamProjectCollectionUri, string triggeredBy, string originalQuality, string newQuality)
        {
            var deploymentEvent = new DeploymentEvent
            {
                BuildNumber = buildNumber,
                TeamProject = teamProject,
                TeamProjectCollectionUri = teamProjectCollectionUri,
                TriggeredUtc             = DateTime.UtcNow,
                TriggeredBy       = triggeredBy,
                OriginalQuality   = originalQuality,
                NewQuality        = newQuality,
                QueuedDeployments = new QueuedDeployment[0]
            };

            lock (_eventsLock)
            {
                _events.Add(deploymentEvent);
                return(_events.Count - 1);
            }
        }
Ejemplo n.º 5
0
        private object ConvertPayload()
        {
            switch (Event)
            {
            case PingEvent.EventString:
                return(PingEvent.FromJson(PayloadText));

            case CommitCommentEvent.EventString:
                return(CommitCommentEvent.FromJson(PayloadText));

            case CreateEvent.EventString:
                return(CreateEvent.FromJson(PayloadText));

            case DeleteEvent.EventString:
                return(DeleteEvent.FromJson(PayloadText));

            case DeploymentEvent.EventString:
                return(DeploymentEvent.FromJson(PayloadText));

            case DeploymentStatusEvent.EventString:
                return(DeploymentStatusEvent.FromJson(PayloadText));

            case ForkEvent.EventString:
                return(ForkEvent.FromJson(PayloadText));

            case GollumEvent.EventString:
                return(GollumEvent.FromJson(PayloadText));

            case InstallationEvent.EventString:
                return(InstallationEvent.FromJson(PayloadText));

            case InstallationRepositoriesEvent.EventString:
                return(InstallationRepositoriesEvent.FromJson(PayloadText));

            case IssueCommentEvent.EventString:
                return(IssueCommentEvent.FromJson(PayloadText));

            case IssuesEvent.EventString:
                return(IssuesEvent.FromJson(PayloadText));

            case LabelEvent.EventString:
                return(LabelEvent.FromJson(PayloadText));

            case MemberEvent.EventString:
                return(MemberEvent.FromJson(PayloadText));

            case MembershipEvent.EventString:
                return(MembershipEvent.FromJson(PayloadText));

            case MilestoneEvent.EventString:
                return(MilestoneEvent.FromJson(PayloadText));

            case OrganizationEvent.EventString:
                return(OrganizationEvent.FromJson(PayloadText));

            case OrgBlockEvent.EventString:
                return(OrgBlockEvent.FromJson(PayloadText));

            case PageBuildEvent.EventString:
                return(PageBuildEvent.FromJson(PayloadText));

            case ProjectCardEvent.EventString:
                return(ProjectCardEvent.FromJson(PayloadText));

            case ProjectColumnEvent.EventString:
                return(ProjectColumnEvent.FromJson(PayloadText));

            case ProjectEvent.EventString:
                return(ProjectEvent.FromJson(PayloadText));

            case PublicEvent.EventString:
                return(PublicEvent.FromJson(PayloadText));

            case PullRequestEvent.EventString:
                return(PullRequestEvent.FromJson(PayloadText));

            case PullRequestReviewEvent.EventString:
                return(PullRequestReviewEvent.FromJson(PayloadText));

            case PullRequestReviewCommentEvent.EventString:
                return(PullRequestReviewCommentEvent.FromJson(PayloadText));

            case PushEvent.EventString:
                return(PushEvent.FromJson(PayloadText));

            case ReleaseEvent.EventString:
                return(ReleaseEvent.FromJson(PayloadText));

            case RepositoryEvent.EventString:
                return(RepositoryEvent.FromJson(PayloadText));

            case StatusEvent.EventString:
                return(StatusEvent.FromJson(PayloadText));

            case WatchEvent.EventString:
                return(WatchEvent.FromJson(PayloadText));

            default:
                throw new NotImplementedException(
                          $"Event Type: `{Event}` is not implemented. Want it added? Open an issue at https://github.com/promofaux/GithubWebhooks");
            }
        }
Ejemplo n.º 6
0
 protected abstract void OnRaiseDeploymentEvent(DeploymentEvent deploymentEvent);
Ejemplo n.º 7
0
 /// <summary>
 /// Raise a deployment event
 /// </summary>
 /// <param name="deploymentEvent">Deployment event</param>
 public void RaiseDeploymentEvent(DeploymentEvent deploymentEvent)
 => OnRaiseDeploymentEvent(deploymentEvent);