Ejemplo n.º 1
0
        public ActionResult UpdateBuildConfig(string id, BuildConfig model)
        {
            string path = GetConfigPath(id);

            SaveConfig(id, path, model, false);

            string lastBuildFile = model.BuildResult;
            var    lastBuild     = JsonStorage.ReadFileOrDefault <LastBuild>(lastBuildFile);

            if (lastBuild == null)
            {
                lastBuild = new LastBuild();
            }
            lastBuild.Error      = "Config changed";
            lastBuild.LastResult = null;
            JsonStorage.WriteFile(lastBuild, lastBuildFile);
            return(Json(model));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Class != null)
         {
             hashCode = hashCode * 59 + Class.GetHashCode();
         }
         if (Name != null)
         {
             hashCode = hashCode * 59 + Name.GetHashCode();
         }
         if (Url != null)
         {
             hashCode = hashCode * 59 + Url.GetHashCode();
         }
         if (Color != null)
         {
             hashCode = hashCode * 59 + Color.GetHashCode();
         }
         if (Actions != null)
         {
             hashCode = hashCode * 59 + Actions.GetHashCode();
         }
         if (Description != null)
         {
             hashCode = hashCode * 59 + Description.GetHashCode();
         }
         if (DisplayName != null)
         {
             hashCode = hashCode * 59 + DisplayName.GetHashCode();
         }
         if (DisplayNameOrNull != null)
         {
             hashCode = hashCode * 59 + DisplayNameOrNull.GetHashCode();
         }
         if (FullDisplayName != null)
         {
             hashCode = hashCode * 59 + FullDisplayName.GetHashCode();
         }
         if (FullName != null)
         {
             hashCode = hashCode * 59 + FullName.GetHashCode();
         }
         if (Buildable != null)
         {
             hashCode = hashCode * 59 + Buildable.GetHashCode();
         }
         if (Builds != null)
         {
             hashCode = hashCode * 59 + Builds.GetHashCode();
         }
         if (FirstBuild != null)
         {
             hashCode = hashCode * 59 + FirstBuild.GetHashCode();
         }
         if (HealthReport != null)
         {
             hashCode = hashCode * 59 + HealthReport.GetHashCode();
         }
         if (InQueue != null)
         {
             hashCode = hashCode * 59 + InQueue.GetHashCode();
         }
         if (KeepDependencies != null)
         {
             hashCode = hashCode * 59 + KeepDependencies.GetHashCode();
         }
         if (LastBuild != null)
         {
             hashCode = hashCode * 59 + LastBuild.GetHashCode();
         }
         if (LastCompletedBuild != null)
         {
             hashCode = hashCode * 59 + LastCompletedBuild.GetHashCode();
         }
         if (LastFailedBuild != null)
         {
             hashCode = hashCode * 59 + LastFailedBuild.GetHashCode();
         }
         if (LastStableBuild != null)
         {
             hashCode = hashCode * 59 + LastStableBuild.GetHashCode();
         }
         if (LastSuccessfulBuild != null)
         {
             hashCode = hashCode * 59 + LastSuccessfulBuild.GetHashCode();
         }
         if (LastUnstableBuild != null)
         {
             hashCode = hashCode * 59 + LastUnstableBuild.GetHashCode();
         }
         if (LastUnsuccessfulBuild != null)
         {
             hashCode = hashCode * 59 + LastUnsuccessfulBuild.GetHashCode();
         }
         if (NextBuildNumber != null)
         {
             hashCode = hashCode * 59 + NextBuildNumber.GetHashCode();
         }
         if (QueueItem != null)
         {
             hashCode = hashCode * 59 + QueueItem.GetHashCode();
         }
         if (ConcurrentBuild != null)
         {
             hashCode = hashCode * 59 + ConcurrentBuild.GetHashCode();
         }
         if (Scm != null)
         {
             hashCode = hashCode * 59 + Scm.GetHashCode();
         }
         return(hashCode);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns true if FreeStyleProject instances are equal
        /// </summary>
        /// <param name="other">Instance of FreeStyleProject to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(FreeStyleProject other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Class == other.Class ||
                     Class != null &&
                     Class.Equals(other.Class)
                     ) &&
                 (
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                 ) &&
                 (
                     Url == other.Url ||
                     Url != null &&
                     Url.Equals(other.Url)
                 ) &&
                 (
                     Color == other.Color ||
                     Color != null &&
                     Color.Equals(other.Color)
                 ) &&
                 (
                     Actions == other.Actions ||
                     Actions != null &&
                     Actions.SequenceEqual(other.Actions)
                 ) &&
                 (
                     Description == other.Description ||
                     Description != null &&
                     Description.Equals(other.Description)
                 ) &&
                 (
                     DisplayName == other.DisplayName ||
                     DisplayName != null &&
                     DisplayName.Equals(other.DisplayName)
                 ) &&
                 (
                     DisplayNameOrNull == other.DisplayNameOrNull ||
                     DisplayNameOrNull != null &&
                     DisplayNameOrNull.Equals(other.DisplayNameOrNull)
                 ) &&
                 (
                     FullDisplayName == other.FullDisplayName ||
                     FullDisplayName != null &&
                     FullDisplayName.Equals(other.FullDisplayName)
                 ) &&
                 (
                     FullName == other.FullName ||
                     FullName != null &&
                     FullName.Equals(other.FullName)
                 ) &&
                 (
                     Buildable == other.Buildable ||
                     Buildable != null &&
                     Buildable.Equals(other.Buildable)
                 ) &&
                 (
                     Builds == other.Builds ||
                     Builds != null &&
                     Builds.SequenceEqual(other.Builds)
                 ) &&
                 (
                     FirstBuild == other.FirstBuild ||
                     FirstBuild != null &&
                     FirstBuild.Equals(other.FirstBuild)
                 ) &&
                 (
                     HealthReport == other.HealthReport ||
                     HealthReport != null &&
                     HealthReport.SequenceEqual(other.HealthReport)
                 ) &&
                 (
                     InQueue == other.InQueue ||
                     InQueue != null &&
                     InQueue.Equals(other.InQueue)
                 ) &&
                 (
                     KeepDependencies == other.KeepDependencies ||
                     KeepDependencies != null &&
                     KeepDependencies.Equals(other.KeepDependencies)
                 ) &&
                 (
                     LastBuild == other.LastBuild ||
                     LastBuild != null &&
                     LastBuild.Equals(other.LastBuild)
                 ) &&
                 (
                     LastCompletedBuild == other.LastCompletedBuild ||
                     LastCompletedBuild != null &&
                     LastCompletedBuild.Equals(other.LastCompletedBuild)
                 ) &&
                 (
                     LastFailedBuild == other.LastFailedBuild ||
                     LastFailedBuild != null &&
                     LastFailedBuild.Equals(other.LastFailedBuild)
                 ) &&
                 (
                     LastStableBuild == other.LastStableBuild ||
                     LastStableBuild != null &&
                     LastStableBuild.Equals(other.LastStableBuild)
                 ) &&
                 (
                     LastSuccessfulBuild == other.LastSuccessfulBuild ||
                     LastSuccessfulBuild != null &&
                     LastSuccessfulBuild.Equals(other.LastSuccessfulBuild)
                 ) &&
                 (
                     LastUnstableBuild == other.LastUnstableBuild ||
                     LastUnstableBuild != null &&
                     LastUnstableBuild.Equals(other.LastUnstableBuild)
                 ) &&
                 (
                     LastUnsuccessfulBuild == other.LastUnsuccessfulBuild ||
                     LastUnsuccessfulBuild != null &&
                     LastUnsuccessfulBuild.Equals(other.LastUnsuccessfulBuild)
                 ) &&
                 (
                     NextBuildNumber == other.NextBuildNumber ||
                     NextBuildNumber != null &&
                     NextBuildNumber.Equals(other.NextBuildNumber)
                 ) &&
                 (
                     QueueItem == other.QueueItem ||
                     QueueItem != null &&
                     QueueItem.Equals(other.QueueItem)
                 ) &&
                 (
                     ConcurrentBuild == other.ConcurrentBuild ||
                     ConcurrentBuild != null &&
                     ConcurrentBuild.Equals(other.ConcurrentBuild)
                 ) &&
                 (
                     Scm == other.Scm ||
                     Scm != null &&
                     Scm.Equals(other.Scm)
                 ));
        }
Ejemplo n.º 4
0
        public ActionResult UpdateBuildConfig(string id)
        {
            string path = IISStore + "\\" + id + "\\build-config.json";

            string formValue = Request.Form["formModel"];

            var model = JsonConvert.DeserializeObject<BuildConfig>(formValue);

            JsonStorage.WriteFile(model, path);

            string lastBuildFile = IISStore + "\\" + id + "\\last-build.json";
            var lastBuild = JsonStorage.ReadFileOrDefault<LastBuild>(lastBuildFile);
            if (lastBuild == null) {
                lastBuild = new LastBuild();
            }
            lastBuild.Error = "Config changed";
            JsonStorage.WriteFile(lastBuild, lastBuildFile);
            return Json(model);
        }
Ejemplo n.º 5
0
        private static LastBuild Execute(BuildConfig config)
        {
            try
            {

                string buildFolder = config.BuildFolder;

                var result = DownloadFilesAsync(config, buildFolder).Result;

                if (result == 0)
                {
                    var lb = JsonStorage.ReadFileOrDefault<LastBuild>(buildFolder + "\\last-build.json");
                    if (lb == null || string.IsNullOrWhiteSpace(lb.Error))
                    {
                        if (lb == null)
                        {
                            lb = new LastBuild { Time = DateTime.UtcNow };
                        }
                        lb.Log = "+++++++++++++++++++++ No changes to deploy +++++++++++++++++++++";
                        lb.ExitCode = 0;
                        lb.Error = "";
                        return lb;
                    }
                }

                if (config.UseMSBuild)
                {
                    var buildCommand = new MSBuildCommand()
                    {
                        Solution = config.SolutionPath,
                        BuildFolder = buildFolder,
                        Parameters = config.MSBuildParameters,
                        BuildConfig = config.MSBuildConfig
                    };

                    var lastBuild = buildCommand.Build();
                    if (!lastBuild.Success)
                    {
                        return lastBuild;
                    }

                    string webConfig = XDTService.Instance.Process(config);

                    IISManager.Instance.DeployFiles(config, webConfig);

                    lastBuild.Log += "\r\n+++++++++++++++++++++ Deployment Successful !!! +++++++++++++++++++++";

                    return lastBuild;
                }
                else {
                    throw new NotImplementedException();
                }

            }
            catch (Exception ex) {
                return new LastBuild { 
                    Error = ex.ToString(),
                    ExitCode = -1,
                    Time = DateTime.UtcNow
                };
            }

        }