Beispiel #1
0
        public JenkinsService([NotNull] ILog logger, [NotNull] AppConfiguration.AppConfiguration appConfiguration)
        {
            this.Logger          = logger;
            this.AllExecInfos    = new BlockingCollection <BuildServerExecutionInfo>();
            this._jenkinsAddress = appConfiguration.Services?.Jenkins?.Address ?? throw new NotSupportedException("Ошибка конфигурации. Не задан сервер Jenkins");


            var name = appConfiguration.Services?.Jenkins?.NetworkCredential?.Name;
            var pass = appConfiguration.Services?.Jenkins?.NetworkCredential?.Password;

            if (string.IsNullOrEmpty(name) && string.IsNullOrEmpty(pass))
            {
            }
            else if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(pass))
            {
                this.JenkinsAuthFunc = request =>
                {
                    string basicAuthToken = Convert.ToBase64String(Encoding.Default.GetBytes("bot:1"));
                    request.Headers["Authorization"] = "Basic " + basicAuthToken;
                };
            }
            else
            {
                throw new NotSupportedException("Ошибка конфигурации auth jenkins");
            }
        }
Beispiel #2
0
        public GitService([NotNull] ILog logger, [NotNull] AppConfiguration.AppConfiguration appConfiguration)
        {
            Logger = logger;
            var gitConfiguration = appConfiguration.Services?.Gits?[0] ?? throw new NotSupportedException("Ошибка конфигурации git");

            this.Bin        = gitConfiguration.Bin ?? throw new NotSupportedException("Ошибка конфигурации git");
            this.Dir        = gitConfiguration.Dir ?? throw new NotSupportedException("Ошибка конфигурации git");
            this.Repository = gitConfiguration.Repository ?? throw new NotSupportedException("Ошибка конфигурации git");
        }
Beispiel #3
0
 public JenkinsProject([NotNull] string name,
                       [NotNull] ILog logger,
                       [NotNull] AppConfiguration.AppConfiguration configuration,
                       [NotNull] IMainBot mainBot,
                       [NotNull] IJenkinsService jenkinsService,
                       [NotNull] IRedmineService redmineService)
 {
     this.Name              = name;
     this.Logger            = logger;
     this.Configuration     = configuration;
     this.MainBot           = mainBot;
     this.JenkinsService    = jenkinsService;
     this.RedmineService    = redmineService;
     this.BuildServerPulles = new List <JenkinsJobInfo>();
     this.VersionCurrent    = "0";
 }
Beispiel #4
0
        public RedmineService([NotNull] IMainBot mainBot, [NotNull] AppConfiguration.AppConfiguration configuration)
        {
            this.MainBot       = mainBot;
            this.ServerAddress = configuration.Services?.Redmine?.Address ?? throw new NotSupportedException("Ошибка конфигурации. Не задан redmine");

            var usr = configuration.Services?.Redmine?.NetworkCredential?.Name;
            var psw = configuration.Services?.Redmine?.NetworkCredential?.Password;

            if (usr == null || psw == null)
            {
                throw new NotSupportedException("Ошибка конфигурации. Не задан пользователь redmine");
            }
            this.NetCredintal = new NetworkCredential(usr, psw);

            this.TasksCache = new List <RedmineTaskDesc>();
        }
Beispiel #5
0
        public MainBot([NotNull] Lazy <ITgClientService> tgService,
                       [NotNull] Lazy <IRedmineService> redmineService,
                       [NotNull] Lazy <IGitService> gitService,
                       [NotNull] AppConfiguration.AppConfiguration configuration,
                       [NotNull] ILog logger)
        {
            this.TgService       = tgService;
            this.GitService      = gitService;
            this.Configuration   = configuration;
            this._redmineService = redmineService;
            this.Logger          = logger;
            this.AllProjects     = new List <IProject>();
            this.AllUsers        = new List <User>();
            this.AllGroups       = new List <Group>();

            this.ConversationFactories = new List <IConversationFactory>
            {
                new GroupVersionConversationFactory(),
                new UserVersionConversationFactory(),
                new UserUnbuildedConversationFactory(),
                new UserStatLongTimeConversationFactory()
            };
            this.IsStarting = true;
        }