UpdateProjectHook() public method

public UpdateProjectHook ( NGitLab.Models.Project project, NGitLab.Models.ProjectHook hook, Uri uri, bool mergeRequestEvents, bool pushEvents, bool buildEvents ) : NGitLab.Models.ProjectHook
project NGitLab.Models.Project
hook NGitLab.Models.ProjectHook
uri System.Uri
mergeRequestEvents bool
pushEvents bool
buildEvents bool
return NGitLab.Models.ProjectHook
示例#1
0
        static int DoListenerWork(ListenerOptions clo) {
            string gitServer = clo.Server;
            string gitlabauthtoken = clo.AuthToken;
            string sharedWebHookPath = clo.WebHook;
            string taskName = clo.FarmTaskName;
            string serviceUser = clo.Login;
            bool supportsSendingMessages = !string.IsNullOrEmpty(taskName);
            Stopwatch sw = Stopwatch.StartNew();

            GitLabWrapper gitLabWrapper = new GitLabWrapper(gitServer, gitlabauthtoken);
            FarmIntegrator.Start(null);

            var projects = gitLabWrapper.GetAllProjects();
            foreach (Project project in projects) {
                var hooks = gitLabWrapper.GetProjectHooks(project);
                foreach (ProjectHook hook in hooks) {
                    if (WebHookHelper.IsSameHost(hook.Url, IP) || !WebHookHelper.IsSharedHook(sharedWebHookPath, hook.Url))
                        continue;
                    Uri url = WebHookHelper.Replace(hook.Url, IP);
                    gitLabWrapper.UpdateProjectHook(project, hook, url, true, true, true);
                    Log.Message($"WebHook registered for project {project.Name} at {url}");
                }
            }

            WebServer server = new WebServer(WebHookHelper.GetSharedHookUrl(IP, sharedWebHookPath));
            server.Start();
            while (sw.Elapsed.Minutes < clo.Timeout) {
                Thread.Sleep(10);
                var request = server.GetRequest();
                if (request == null)
                    continue;
                ProcessWebHook(gitLabWrapper, serviceUser, request, supportsSendingMessages, taskName);
            }

            return 0;
        }