Exemplo n.º 1
0
        /// <summary>
        /// Aggregates files from various Versions into one Version
        /// </summary>
        /// <param name="aggregated"></param>
        /// <param name="directory"></param>
        /// <returns></returns>
        public static Version AggregateVersion(AggregatedChangelog aggregated, DirectoryStructure directory)
        {
            var            versions = new Dictionary <string, Version>();
            VersionBuilder builder  = new VersionBuilder();
            Action <Dictionary <string, Tuple <string, Commit> > > build = vals =>
            {
                foreach (var val in vals)
                {
                    string  versionHash = val.Value.Item2.Version.Hash;
                    Version v;
                    if (versions.ContainsKey(versionHash))
                    {
                        v = versions[versionHash];
                    }
                    else
                    {
                        v = directory.GetVersion(versionHash);
                        versions.Add(v.Hash, v);
                    }
                    var vdata = v.GetVersionData(val.Key);
                    builder.AddVersionData(val.Key, vdata);
                }
            };

            build(aggregated.Added);
            build(aggregated.Modified);
            foreach (var pair in aggregated.Renamed)
            {
                builder.RenameVersionData(pair.Key, pair.Value);
            }
            return(builder.GetVersion());
        }
Exemplo n.º 2
0
    public string push2Master()
    {
        CurrentContext.ValidateAdmin();
        string res = VersionBuilder.PushRelease();

        VersionBuilder.SendVersionAlarm();
        return(res + "<br/>Finished!");
    }
Exemplo n.º 3
0
        public Task <VersionResponse> GetVersion()
        {
            // Get version
            var version = VersionBuilder.BuildVersion(Assembly.GetExecutingAssembly());

            // Response
            var response = _mapper.Map <VersionResponse>(version);

            // Return
            return(Task.FromResult(response));
        }
Exemplo n.º 4
0
    public async Task <bool> SetGloabalDispo(int ttid, GlobalDispo dispo, string email)
    {
        var dispRef = await DefectDispo.GetDispoFromGlobal(dispo);

        string currentlock = Guid.NewGuid().ToString();
        var    user        = DefectUser.FindByEmail(email);

        if (user == null)
        {
            return(false);
        }
        LockInfo li = await Defect.LocktaskAsync(ttid.ToString(), currentlock, user.TRID.ToString(), true);

        Defect d = new Defect(ttid);

        d.SetUpdater(new MPSUser(user.TRID));
        d.DISPO = dispRef.idRecord.ToString();
        if (d.PRIMARYHOURS == null)
        {
            d.PRIMARYHOURS = d.SPENT;
        }
        d.Store();
        DefectEvent.AddEventByTask(d.IDREC, DefectEvent.Eventtype.QualityAssurance, user.ID, "Changed disposition to " + dispo);
        await Defect.UnLocktaskAsync(user.TRID.ToString(), currentlock);

        var settings = Settings.CurrentSettings;

        if (d.ID.ToString() == settings.RELEASETTID)
        {
            if (dispo == GlobalDispo.testStarted)
            {
                VersionBuilder.SendAlarm("✅Release build has been finished. Testing is starting...");
            }
            else
            {
                VersionBuilder.SendAlarm("❌Failed to build version. Please check the logs!!!");
            }
        }
        else
        {
            DefectUser du     = new DefectUser(d.AUSER);
            MPSUser    worker = new MPSUser(du.TRID);
            var        attr   = dispo.GetAttributeOfType <DisplayAttribute>();
            TasksBot.SendMessage(worker.CHATID, $"{attr.Description}. The task tests have been marked as {dispRef.Descriptor} by automation system. {settings.GetTTAnchor(ttid, attr.Name)}");
            if (dispo == GlobalDispo.testStarted)
            {
                string mess = $"New task from {user.FULLNAME} is ready for tests!{settings.GetTTAnchor(ttid, d.FIRE ? "taskfire.png" : "")}";
                await TestChannel.SendMessageAsync(mess);
            }
        }
        return(true);
    }
Exemplo n.º 5
0
    public void FailBuild(int id)
    {
        DefectBuild b = new DefectBuild(id)
        {
            STATUS = DefectBuild.BuildStatus.failed.ToString()
        };

        b.Store();
        if (Settings.CurrentSettings.RELEASETTID == b.TTID.ToString())
        {
            VersionBuilder.SendAlarm("❌Failed to build version. Please check the logs!!!");
        }
    }
Exemplo n.º 6
0
    public string scheduledBuild()
    {
        if (HttpContext.Current.Request.Url.Host.ToUpper() != "LOCALHOST")
        {
            return("Rejected: Schedule can be run only locally.");
        }
        MPSUser u = MPSUser.FindUserbyPhone(Settings.CurrentSettings.AUTOBOTPHONE);

        if (u == null || !u.ISADMIN)
        {
            return("No auto bot users found with admin rights.");
        }
        CurrentContext.User = u;
        VersionBuilder.PrepareGit();
        VersionBuilder.VersionIncrement();
        VersionBuilder.PushRelease();
        VersionBuilder.SendVersionAlarm();
        addBuildByTask(Settings.CurrentSettings.RELEASETTID, "Automated Build", btboth);
        return("OK");
    }
Exemplo n.º 7
0
 public void alertVersion()
 {
     CurrentContext.ValidateAdmin();
     VersionBuilder.SendVersionAlarm();
 }
Exemplo n.º 8
0
 public int?GetBuilderID()
 {
     CurrentContext.ValidateAdmin();
     return(VersionBuilder.GetLock());
 }
Exemplo n.º 9
0
 public string versionIncrement()
 {
     CurrentContext.ValidateAdmin();
     return(VersionBuilder.VersionIncrement());
 }
Exemplo n.º 10
0
 public string getUpdateWorkGit()
 {
     CurrentContext.ValidateAdmin();
     return(VersionBuilder.PrepareGit());
 }
Exemplo n.º 11
0
    public void FinishBuild(int id, string requestguid)
    {
        try
        {
            DefectBuild b = new DefectBuild(id)
            {
                STATUS = DefectBuild.BuildStatus.finishedok.ToString(), TESTGUID = requestguid
            };
            b.Store();

            if (Settings.CurrentSettings.RELEASETTID == b.TTID.ToString() && b.TYPE == (int)DefectBuild.BuildType.releasebuild)
            {
                //release builder sends its own notifications
                return;
            }

            Defect     d = new Defect(b.TTID);
            DefectUser u = new DefectUser(b.TTUSERID);
            d.SetUpdater(new MPSUser(u.TRID));
            List <DefectDispo> dsps = DefectDispo.EnumTestsStarted();
            if (dsps.Count > 0)
            {
                string   currentlock = Guid.NewGuid().ToString();
                LockInfo li          = Defect.Locktask(b.TTID.ToString(), currentlock, u.TRID.ToString(), true);
                d.DISPO = dsps[0].ID.ToString();
                if (d.PRIMARYHOURS == null)
                {
                    d.PRIMARYHOURS = d.SPENT;
                }
                d.Store();
                DefectEvent.AddEventByTask(id, DefectEvent.Eventtype.QualityAssurance, b.TTUSERID, "Sent for QA Automation");
                Defect.UnLocktask(u.TRID.ToString(), currentlock);
            }

            if (Settings.CurrentSettings.RELEASETTID == b.TTID.ToString())
            {
                VersionBuilder.SendAlarm("✅New internal release build has been finished. Testing is starting...");
            }
            else
            {
                try
                {
                    string mess = $"New task from {u.FULLNAME} is ready for tests!{Settings.CurrentSettings.GetTTAnchor(b.TTID, d.FIRE ? "taskfire.png" : "")}";
                    TestChannel.SendMessage(mess);
                }
                catch (Exception e)
                {
                    Logger.Log(e);
                }
            }

            string bst_b = d.BSTBATCHES.Trim();
            string bst_c = d.BSTCOMMANDS.Trim();
            if (!string.IsNullOrEmpty(bst_b) || !string.IsNullOrEmpty(bst_c))
            {
                string batches  = string.Join(",", bst_b.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries));
                string commands = string.Join(",", bst_c.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries));
                using (var wcClient = new WebClient())
                {
                    var reqparm = new NameValueCollection();
                    reqparm.Add("guid", requestguid);
                    reqparm.Add("commaseparatedbatches", batches);
                    reqparm.Add("commaseparatedcommands", commands);
                    reqparm.Add("priority", d.TESTPRIORITY);
                    //reqparm.Add("branch", d.BRANCHBST);
                    wcClient.UploadValues(Settings.CurrentSettings.BSTSITESERVICE + "/StartTest", reqparm);
                }
            }
        }
        catch (Exception e)
        {
            Logger.Log(e);
        }
    }
Exemplo n.º 12
0
 public void VersionBuildAlarm(string message)
 {
     VersionBuilder.SendAlarm($"{message}");
 }