Esempio n. 1
0
File: Build.cs Progetto: wangn6/rep2
 public static void Delete(Build build)
 {
     using (ES1AutomationEntities context = new ES1AutomationEntities())
     {
         context.Builds.Attach(build);
         context.Builds.Remove(build);
         context.SaveChanges();
     }
 }
Esempio n. 2
0
File: Build.cs Progetto: wangn6/rep2
 public static Build Add(Build build)
 {
     using (ES1AutomationEntities context = new ES1AutomationEntities())
     {
         Build b = context.Builds.Add(build);
         context.SaveChanges();
         return b;
     }
 }
Esempio n. 3
0
 public static string CodecoverageLine(int productId, Build build, AutomationTask task)
 {
     if (productId == 3)//Data Protection Search
     {
         return "<a href=\"http://10.98.26.221/api/" + build.Number + "\" style=\"color:#43c1d7; text-decoration:underline;\">Detail</a>";
     }
     else if (productId == 2)//CIS
     {
         return "<a href=\"http://10.98.28.192:8080/" + task.TaskId + "/" + task.GetJobs().First().JobId + "/coverage" + "\" style=\"color:#43c1d7; text-decoration:underline;\">Detail</a>";
     }
     return "TBD";
 }
Esempio n. 4
0
 private static void CopyBuildToTestAgentMachine(Build build)
 {
     string message = string.Format("Start to copy build [{0}] to local test agent machine..", build.Name);
     SaberAgent.Log.logger.Info(message);
     SaberAgent.RunningJob.AddJobProgressInformation(message);
     FileHelper.EmptyFolder(buildPathOnTestAgent);
     string buildRootPath = build.Location;
     Product product = Product.GetProductByID(build.ProductId);
     if (product.Name == "SourceOne")//hard coded, TODO to change it configurable?
     {
         string cdRoomPath = System.IO.Path.Combine(buildRootPath, ES1CDRoomRaletivePath);
         SaberAgent.Log.logger.Info(string.Format("Start to copy build installation files from {0} to {1}", cdRoomPath, buildPathOnTestAgent));
         FileHelper.CopyDirectoryWithParentFolder(cdRoomPath, buildPathOnTestAgent);
         cdRoomPath = System.IO.Path.Combine(buildRootPath, DISCOCDRoomRaletivePath);
         SaberAgent.Log.logger.Info(string.Format("Start to copy build installation files from {0} to {1}", cdRoomPath, buildPathOnTestAgent));
         FileHelper.CopyDirectoryWithParentFolder(cdRoomPath, buildPathOnTestAgent);
     }
     else if (product.Name == "Supervisor Web")//hard coded, TODO to change it configurable?
     {
         string cdRoomPath = System.IO.Path.Combine(buildRootPath, SupvisorCDRoomRaletivePath);
         SaberAgent.Log.logger.Info(string.Format("Start to copy build installation files from {0} to {1}", cdRoomPath, buildPathOnTestAgent));
         FileHelper.CopyDirectoryWithParentFolder(cdRoomPath, buildPathOnTestAgent);
     }
     message = string.Format("Build is coped to the Test Agent Machine.");
     SaberAgent.Log.logger.Info(message);
     SaberAgent.RunningJob.AddJobProgressInformation(message);
 }
Esempio n. 5
0
        private static void AuthenticateRemoteServer(Build build)
        {
            SaberAgent.Log.logger.Info(string.Format("Net use the remote build server before copy any build from it."));

            string remoteServer = string.Empty;
            string buildLocation = build.Location;
            remoteServer = buildLocation.Split(new[] { '\\' }, StringSplitOptions.RemoveEmptyEntries)[0];

            SaberAgent.Log.logger.Info(string.Format("Remote Server is {0}", remoteServer));
            SaberAgent.Log.logger.Info(string.Format("Net use machine {0} as user {1} with paswword {2}", remoteServer, buildServerUser, buildServerPassword));
            NetUseHelper.NetUserMachine(remoteServer, buildServerUser, buildServerPassword);
            SaberAgent.Log.logger.Info(string.Format("The remote server {0} is authenticated.", remoteServer));
        }
Esempio n. 6
0
        public void SyncAllBuilds()
        {
            IList<Build> builds = GetAllBuildsOnCISBuildServer();

            foreach (Build buildOnBuildFileServer in builds)
            {
                Build buildOnDB = Build.GetBuildByLocation(buildOnBuildFileServer.Location);

                if (buildOnDB != null)
                {
                }
                else
                {
                    buildOnDB = new Build
                    {
                        Name = buildOnBuildFileServer.Name,
                        Location = buildOnBuildFileServer.Location,
                        Description = buildOnBuildFileServer.Description,
                        BuildStatus = BuildStatus.Success,
                        BranchId = buildOnBuildFileServer.BranchId,
                        ReleaseId = buildOnBuildFileServer.ReleaseId,
                        BuildType = buildOnBuildFileServer.BuildType,
                        Number = buildOnBuildFileServer.Number,
                        ProductId = buildOnBuildFileServer.ProductId,
                        ProviderId = this.Provider.ProviderId,
                    };

                    Build.Add(buildOnDB);
                }
            }
        }
Esempio n. 7
0
 public void DeleteBuild(Build build)
 {
     Build.Delete(build);
 }
Esempio n. 8
0
        private void getBuildsInFolder(IList<Build> builds, string rootFolder, string branchFolder, System.Text.RegularExpressions.Regex buildFolderPattern)
        {
            foreach (string d in System.IO.Directory.GetDirectories(rootFolder))
            {
                System.IO.DirectoryInfo info = new System.IO.DirectoryInfo(d);

                string buildName = info.Name;

                if (buildFolderPattern.IsMatch(buildName))
                {

                    string releaseName = buildName.Substring(0, buildName.LastIndexOf('.'));

                    string number = info.Name.Substring(buildName.LastIndexOf('.') + 1);

                    System.IO.DirectoryInfo remoteInfo = new System.IO.DirectoryInfo(d.Replace(localMapFolder, Path));

                    Branch tempBranch = new Branch
                    {
                        Name = branchFolder,
                        Path = string.Empty,
                        Description = branchFolder,
                        Type = (int)SyncSourceType.FromBuildServer,
                        ProductId = Product.GetProductByName(ProductName).ProductId,
                    };

                    Branch branch = Branch.AddOrUpdateBranch(tempBranch);

                    Release tempRelease = new Release
                    {
                        Name = releaseName,
                        Description = releaseName,
                        Type = (int)SyncSourceType.FromBuildServer,
                        Path = string.Empty,
                        ProductId = Product.GetProductByName(ProductName).ProductId,
                    };

                    Release release = Release.AddOrUpdateRelease(tempRelease);

                    if (IsBuildFinished(info))
                    {
                        Build b = new Build
                        {
                            Name = info.Name,
                            Description = info.Name,
                            Location = remoteInfo.FullName,
                            BranchId = branch.BranchId,
                            ReleaseId = release.ReleaseId,
                            Number = number,
                            BuildType = BuildType.BuildMachine,
                            ProductId = Product.GetProductByName("Common Index Search").ProductId,
                            BuildStatus = BuildStatus.Success,
                        };

                        builds.Add(b);
                    }
                }
                else
                {
                    string tempBranchFolder = string.IsNullOrEmpty(branchFolder) ? info.Name : branchFolder + @"\" + info.Name;

                    getBuildsInFolder(builds, d, tempBranchFolder, buildFolderPattern);
                }
            }
        }
Esempio n. 9
0
        public void UpdateBuildStatus(Build build)
        {
            if (build.BuildStatus == BuildStatus.Success)
            {
                if (System.IO.Directory.Exists(build.Location.Replace(Path, localMapFolder)))
                {
                    //check whether the install folder exist or not

                    //keep as it is
                }
                else
                {
                    build.BuildStatus = BuildStatus.Delete;
                    build.Update();
                }
            }
            else if (build.BuildStatus == BuildStatus.NotExist)
            {
                if (System.IO.Directory.Exists(build.Location.Replace(Path, localMapFolder)))
                {
                    build.BuildStatus = BuildStatus.Success;
                    build.Update();
                }
                else
                {
                    //keep as it is
                }
            }
        }
Esempio n. 10
0
        public IList<Build> GetAllBuildsOnBuildFileServer()
        {
            List<Build> builds = new List<Build>();
            //update SourceOne builds
            const string BuildFolderIndexName = "PATH";
            const string BuildPatternIndexName="PATTERN";
            const string BuildBranchIndexName = "BRANCH";

            List<Dictionary<string, string>> buildFoldersList = new List<Dictionary<string, string>>();

            string es1Main = System.IO.Path.Combine(localMapFolder + @"\", mainlineBuildFolder);
            Dictionary<string, string> temp = new Dictionary<string, string>();
            temp[BuildFolderIndexName] = es1Main;
            temp[BuildPatternIndexName] = mainlineBuildNamingPattern;
            temp[BuildBranchIndexName] = "Mainline";
            buildFoldersList.Add(temp);

            string featureBranch = System.IO.Path.Combine(localMapFolder + @"\", featureBranchBuildFolder);
            temp = new Dictionary<string, string>();
            temp[BuildFolderIndexName] = featureBranch;
            temp[BuildPatternIndexName] = featureBranchBuildNamingPatern;
            temp[BuildBranchIndexName] = string.Empty;
            buildFoldersList.Add(temp);

            string[] maintBranches = System.IO.Directory.GetDirectories(localMapFolder + @"\", maintBranchBuildFolderPattern);
            foreach (string maintBranch in maintBranches)
            {
                temp = new Dictionary<string, string>();
                temp[BuildFolderIndexName] = maintBranch;
                temp[BuildPatternIndexName] = maintBranchBuildNamingPattern;
                temp[BuildBranchIndexName] = new System.IO.DirectoryInfo(maintBranch).Name;//The branch name is the folder name
                buildFoldersList.Add(temp);
            }

            foreach (Dictionary<string, string> buildFolder in buildFoldersList)
            {
                foreach (string d in System.IO.Directory.GetDirectories(buildFolder[BuildFolderIndexName], buildFolder[BuildPatternIndexName]))
                {
                    if (!d.Contains("BAD"))
                    {
                        System.IO.DirectoryInfo info = new System.IO.DirectoryInfo(d);

                        System.IO.DirectoryInfo remoteInfo = new System.IO.DirectoryInfo(d.Replace(localMapFolder, Path));

                        string branchName = string.IsNullOrEmpty(buildFolder[BuildBranchIndexName]) ? System.Text.RegularExpressions.Regex.Split(info.Name, @"_[0-9]\.[0-9]\.[0-9]\.[0-9]+")[0] : buildFolder[BuildBranchIndexName];
                        string releaseAndNumber = System.Text.RegularExpressions.Regex.Match(info.Name, @"[0-9]\.[0-9]\.[0-9]\.[0-9]+").Value;
                        string number = releaseAndNumber.Substring(releaseAndNumber.LastIndexOf('.') + 1);
                        string releaseName = releaseAndNumber.Substring(0, releaseAndNumber.LastIndexOf('.'));
                        Branch tempBranch = new Branch
                        {
                            Name = branchName,
                            Path = string.Empty,
                            Description = branchName,
                            Type = (int)SyncSourceType.FromBuildServer,
                            ProductId = Product.GetProductByName(ProductName).ProductId,
                        };
                        Branch branch = Branch.AddOrUpdateBranch(tempBranch);
                        Release tempRelease = new Release
                        {
                            Name = releaseName,
                            Description = releaseName,
                            Type = (int)SyncSourceType.FromBuildServer,
                            Path = string.Empty,
                            ProductId = Product.GetProductByName(ProductName).ProductId,
                        };
                        Release release = Release.AddOrUpdateRelease(tempRelease);

                        if (IsBuildFinished(info))
                        {
                            Build b = new Build
                            {
                                Name = info.Name,
                                Description = info.Name,
                                Location = remoteInfo.FullName,
                                BranchId = branch.BranchId,
                                ReleaseId = release.ReleaseId,
                                Number = number,
                                BuildType = BuildType.BuildMachine,
                                ProductId = Product.GetProductByName(ProductName).ProductId,
                                BuildStatus = BuildStatus.Success,
                                ProviderId = this.Provider.ProviderId,
                            };
                            builds.Add(b);
                        }
                    }
                }
            }
            return builds;
        }
 public static void Initialize(TestEnvironment environment)
 {
     DPSearchBuilderInstallerHelper.environment = environment;
     DPSearchBuilderInstallerHelper.config = new TestEnvironmentConfigHelper(environment.Config);
     DPSearchBuilderInstallerHelper.sutDomainName = config.SUTConfiguration.SUTDomainConfig.Name;
     DPSearchBuilderInstallerHelper.sutDomainAdmin = config.SUTConfiguration.SUTDomainConfig.Adminstrator;
     DPSearchBuilderInstallerHelper.sutDomainAdminPassword = config.SUTConfiguration.SUTDomainConfig.Password;
     DPSearchBuilderInstallerHelper.remoteAgent = getRemoteAgent();
     DPSearchBuilderInstallerHelper.job = getAutomationJob();
     DPSearchBuilderInstallerHelper.build = getBuild();
 }
Esempio n. 12
0
        public void SyncAllBuilds()
        {
            string mainlineFolder = string.Format(@"{0}\SUP_Main", localMapFolder);
            foreach (string d in Directory.GetDirectories(mainlineFolder, buildPattern))
            {
                if (!d.Contains("BAD"))
                {
                    DirectoryInfo info = new System.IO.DirectoryInfo(d);
                    DirectoryInfo remoteInfo = new System.IO.DirectoryInfo(d.Replace(localMapFolder, path));

                    string branchName = System.Text.RegularExpressions.Regex.Split(info.Name, @"_[0-9]\.[0-9][0-9]\.[0-9]+")[0];
                    string releaseAndNumber = System.Text.RegularExpressions.Regex.Match(info.Name, @"[0-9]\.[0-9][0-9]\.[0-9]+").Value;
                    string number = releaseAndNumber.Substring(releaseAndNumber.LastIndexOf('.') + 1);
                    string releaseName = releaseAndNumber.Substring(0, releaseAndNumber.LastIndexOf('.'));
                    Branch tempBranch = new Branch
                    {
                        Name = branchName,
                        Path = string.Empty,
                        Description = branchName,
                        Type = (int)SyncSourceType.FromBuildServer,
                        ProductId = Product.GetProductByName(productName).ProductId,
                    };
                    Branch branch = Branch.AddOrUpdateBranch(tempBranch);
                    Release tempRelease = new Release
                    {
                        Name = releaseName,
                        Description = releaseName,
                        Type = (int)SyncSourceType.FromBuildServer,
                        Path = string.Empty,
                        ProductId = Product.GetProductByName(productName).ProductId,
                    };
                    Release release = Release.AddOrUpdateRelease(tempRelease);

                    if (IsBuildFinished(info))
                    {
                        Build b = new Build
                        {
                            Name = info.Name,
                            Description = info.Name,
                            Location = remoteInfo.FullName,
                            BranchId = branch.BranchId,
                            ReleaseId = release.ReleaseId,
                            Number = number,
                            BuildType = BuildType.BuildMachine,
                            ProductId = Product.GetProductByName(productName).ProductId,
                            BuildStatus = BuildStatus.Success,
                            ProviderId = Provider.ProviderId,
                        };
                        if (null == Build.GetBuildByLocation(b.Location))
                        {
                            Build.Add(b);
                        }
                    }
                }
            }
        }
Esempio n. 13
0
        private void BuildEvaluateList(GameSnapshotModel snapshot)
        {
            List <Build> newNotifications = new List <Build>(), removedNotifications = new List <Build>(), changedNotifications = new List <Build>();

            lock (mutex)
            {
                int oldNumber    = _currentBuilds.Count;
                int newNumber    = snapshot.ProjectPct.Length;
                int commonNumber = Math.Min(oldNumber, newNumber);
                for (int i = 0; i < commonNumber; i++)
                {
                    var curr     = _currentBuilds[i];
                    var newValue = snapshot.ProjectPct[i];
                    if (curr.Value != newValue)
                    {
                        if (curr.Value == 0)
                        {
                            newNotifications.Add(curr);
                        }
                        else if (newValue == 0)
                        {
                            removedNotifications.Add(curr);
                        }
                        else
                        {
                            changedNotifications.Add(curr);
                        }
                        curr.Value = newValue;
                    }
                }
                for (int i = oldNumber; i < newNumber; i++)
                {
                    var newValue     = snapshot.ProjectPct[i];
                    var notification = new Build()
                    {
                        Number = i, Value = newValue
                    };
                    if (newValue > 0)
                    {
                        newNotifications.Add(notification);
                    }
                    _currentBuilds.Add(notification);
                }
                for (int i = newNumber; i < oldNumber; i++)
                {
                    var curr = _currentBuilds[i];
                    if (curr.Value > 0)
                    {
                        removedNotifications.Add(curr);
                    }
                }
                if (newNumber < oldNumber)
                {
                    _currentBuilds.RemoveRange(newNumber, newNumber - oldNumber);
                }
            }
            if (newNotifications.Count > 0)
            {
                FireNewBuildNotification(newNotifications);
            }
            if (changedNotifications.Count > 0)
            {
                FireChangedBuildNotification(changedNotifications);
            }
            if (removedNotifications.Count > 0)
            {
                FireRemovedBuildNotification(removedNotifications);
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Invoked when <see cref="ToEntity"/> operation is about to return.
        /// </summary>
        /// <param name="entity"><see cref="Build"/> converted from <see cref="BuildDTO"/>.</param>
partial         static void OnEntity(this BuildDTO dto, Build entity);
Esempio n. 15
0
        /// <summary>
        /// Converts this instance of <see cref="BuildDTO"/> to an instance of <see cref="Build"/>.
        /// </summary>
        /// <param name="dto"><see cref="BuildDTO"/> to convert.</param>
        public static Build ToEntity(this BuildDTO dto)
        {
            if (dto == null) return null;

            var entity = new Build();

            entity.BuildId = dto.BuildId;
            entity.ProviderId = dto.ProviderId;
            entity.ProductId = dto.ProductId;
            entity.Name = dto.Name;
            entity.Type = dto.Type;
            entity.Status = dto.Status;
            if (Branch.GetBranchByName(dto.Branch) != null)
            {
                entity.BranchId = Branch.GetBranchByName(dto.Branch).BranchId;
            }
            if (Release.GetReleaseByName(dto.Release) != null)
            {
                entity.ReleaseId = Release.GetReleaseByName(dto.Release).ReleaseId;
            }
            entity.Number = dto.Number;
            entity.Location = dto.Location;
            entity.Description = dto.Description;

            dto.OnEntity(entity);

            return entity;
        }
Esempio n. 16
0
 public static void Initialize(TestEnvironment environment)
 {
     CISBuilderInstallerHelper.environment = environment;
     CISBuilderInstallerHelper.config = new TestEnvironmentConfigHelper(environment.Config);
     CISBuilderInstallerHelper.job = getAutomationJob();
     CISBuilderInstallerHelper.build = getBuild();
 }