示例#1
0
文件: JiraPlugin.cs 项目: asek-ll/tst
        private async void SetPluginsEnabled(JiraManager jiraManager, bool enabled)
        {
            foreach (var plugin in _pluginModuleManager.GetSelectedPlugins())
            {
                var httpStatusCode = await jiraManager.UpdatePluginEvabledState(plugin.Key, enabled);

                var isDone = httpStatusCode == HttpStatusCode.OK;

                _logger.Log(string.Format("{0} enabled {1} is {2}", plugin.Key, enabled, httpStatusCode), isDone ? MessageType.OK : MessageType.ERROR);

                if (isDone)
                {
                    plugin.Enabled = enabled;
                }
            }
        }
示例#2
0
文件: JiraPlugin.cs 项目: asek-ll/tst
        private async void RedeployPlugin(JiraManager jiraManager, IEnumerable <PluginModule> plugins, bool localServerMode)
        {
            await jiraManager.setWebSudo();

            var enabledKeysBefore = await jiraManager.GetEnabledPluginKeys();

            var allPluginsIntalled = true;

            foreach (var plugin in plugins)
            {
                var fileUrl = GetFileUrl(plugin.PomPath);
                if (fileUrl == null)
                {
                    continue;
                }

                _logger.Log(string.Format("Start uninstall plugin {0}...", plugin.Key));
                var uninstallState = await jiraManager.UninstallPlugin(plugin.Key);

                _logger.Log(string.Format("Uninstall plugin {0} is {1}", plugin.Key, uninstallState), uninstallState ? MessageType.OK : MessageType.ERROR);

                _logger.Log(string.Format("Start install plugin {0}...", plugin.Key));
                string link;

                if (localServerMode)
                {
                    link = (await jiraManager.InstallPluginToLocalServer(plugin.Key, fileUrl)).ToString();
                }
                else
                {
                    link = (await jiraManager.InstallPlugin(plugin.Key, fileUrl)).ToString();
                }

                _logger.Log(string.Format("Install plugin {0} is {1}", plugin.Key, link));

                var plugin1           = plugin;
                var isPluginInstalled = await jiraManager.CheckLink(link.ToString(), (isSuccess, attemptCount) =>
                {
                    if (isSuccess)
                    {
                        _logger.Success(string.Format("Install plugin {0} successfull", plugin1.Key));
                        return(true);
                    }

                    if (attemptCount > 10)
                    {
                        _logger.Error(string.Format("Install plugin {0} failed", plugin1.Key));
                        return(false);
                    }

                    _logger.Log(string.Format("Install plugin {0} attempt {1}", plugin1.Key, attemptCount));
                    return(true);
                });

                if (!isPluginInstalled)
                {
                    allPluginsIntalled = false;
                }
            }

            if (!allPluginsIntalled)
            {
                return;
            }

            var enabledKeysAfter = await jiraManager.GetEnabledPluginKeys();

            var notEnabledKeys = enabledKeysBefore.Except(enabledKeysAfter);

            if (notEnabledKeys.Count() > 0)
            {
                _logger.Log("Disabled keys: " + String.Join(", ", notEnabledKeys) + ", attempt to re-enable");


                foreach (var key in notEnabledKeys)
                {
                    var httpStatusCode = await jiraManager.UpdatePluginEvabledState(key, true);

                    var isDone = httpStatusCode == HttpStatusCode.OK;

                    _logger.Log(string.Format("{0} enabled is {1}", key, httpStatusCode), isDone ? MessageType.OK : MessageType.ERROR);
                }
            }
        }