コード例 #1
0
 private static bool DoBuild(
     IActivityMonitor m,
     ISolutionDriver driver,
     CSVersion targetVersion,
     out bool tagCreated)
 {
     tagCreated = false;
     try
     {
         var git = driver.GitRepository;
         if (targetVersion.PackageQuality == PackageQuality.Release)
         {
             if (!git.SwitchDevelopToMaster(m))
             {
                 return(false);
             }
             driver = driver.GetCurrentBranchDriver();
         }
         if (!git.SetVersionTag(m, targetVersion))
         {
             return(false);
         }
         tagCreated = true;
         if (!driver.Build(m, withUnitTest: true, withZeroBuilder: true, withPushToRemote: false))
         {
             return(false);
         }
         return(true);
     }
     catch (Exception ex)
     {
         m.Error("Build failed.", ex);
         return(false);
     }
 }
コード例 #2
0
 protected override BuildState Build(IActivityMonitor m, DependentSolution s, ISolutionDriver driver, IReadOnlyList <UpdatePackageInfo> upgrades, SVersion sVersion, IReadOnlyCollection <UpdatePackageInfo> buildProjectsUpgrade)
 {
     if (!driver.UpdatePackageDependencies(m, buildProjectsUpgrade))
     {
         return(BuildState.Failed);
     }
     if (!driver.GitRepository.AmendCommit(m, null, date => _commitTimes[s.Index]))
     {
         return(BuildState.Failed);
     }
     return(driver.Build(m, withUnitTest: _withUnitTest, withZeroBuilder: true, withPushToRemote: false)
             ? BuildState.Succeed
             : BuildState.Failed);
 }
コード例 #3
0
 protected override BuildState Build(IActivityMonitor m, DependentSolution s, ISolutionDriver driver, IReadOnlyList <UpdatePackageInfo> upgrades, SVersion sVersion, IReadOnlyCollection <UpdatePackageInfo> buildProjectsUpgrade)
 {
     if (_commits[s.Index] != driver.GitRepository.Head.CommitSha)
     {
         m.Error($"Commit changed between PrepareBuild call and this Build. Build canceled.");
         return(BuildState.Failed);
     }
     if (!driver.UpdatePackageDependencies(m, buildProjectsUpgrade))
     {
         return(BuildState.Failed);
     }
     if (driver.GitRepository.CanAmendCommit)
     {
         if (!driver.GitRepository.AmendCommit(m))
         {
             return(BuildState.Failed);
         }
     }
     else
     {
         if (!driver.GitRepository.Commit(m, "Required Build commit (for CI): build dependencies changed."))
         {
             return(BuildState.Failed);
         }
         var currentSha = driver.GitRepository.Head.CommitSha;
         if (_commits[s.Index] != currentSha)
         {
             m.Warn("A required commit has been created because build dependencies changed whereas normal ones didn't and commit cannot be amended. Build will be be retried.");
             _commits[s.Index] = currentSha;
             return(BuildState.MustRetry);
         }
     }
     if (sVersion == null)
     {
         m.Trace("Retry mode: skipping actual build.");
         return(BuildState.MustRetry);
     }
     return(driver.Build(m, _withUnitTest, withZeroBuilder: true, withPushToRemote: false)
             ? BuildState.Succeed
             : BuildState.Failed);
 }