Example #1
0
 public ReleaseStack(BuildVersion build, string environment)
     : base(build)
 {
     this.environment = environment;
 }
Example #2
0
 protected StackBase(BuildVersion build)
 {
     this.version   = build;
     this.startTime = DateTime.Now;
 }
Example #3
0
        static int DoDeploy(ParsedOpts args)
        {
            const string environment = "qa";

            DateTime     startTime      = DateTime.Now;
            BuildVersion version        = GetLastVersion();
            string       deployedCommit = GetDeployedCommit(environment);

            if (deployedCommit != version.Commit)
            {
                List <Revision> log     = GetMasterLog();
                List <Revision> changes = GetDelta(
                    log,
                    log[0].Commit,
                    deployedCommit
                    );
                if (changes != null && changes.Count > 0)
                {
                    Console.WriteLine("Commits to be deployed:");
                    PrintChangeLog(changes);
                }
            }
            else if (!args["force"].Flag)
            {
                Console.WriteLine(
                    "Latest release is for this build, nothing to do."
                    );
                return(0);
            }

            if (!Confirm())
            {
                Console.WriteLine("Aborting.");
                return(3);
            }

            Console.WriteLine(
                "Deploying {0} to {1} @ {2}",
                version,
                environment,
                startTime
                );
            string[] oldStackIds = GetOldReleaseStacks(environment);
            if (oldStackIds.Length > 0)
            {
                Console.WriteLine("Existing stacks are:");
                for (int i = 0; i < oldStackIds.Length; i++)
                {
                    Console.WriteLine("    {0}", oldStackIds[i]);
                }
            }

            string stackId   = CreateStack(new ReleaseStack(version, environment));
            bool   succeeded = WaitForStackCreated(stackId) &&
                               WaitForStackHealthy(stackId);

            if (succeeded)
            {
                Console.WriteLine("CREATE SUCCESS");
                Console.WriteLine("Cleaning up old stacks...");
                for (int i = 0; i < oldStackIds.Length; i++)
                {
                    DeleteStack(oldStackIds[i]);
                }

                Console.WriteLine("DEPLOY SUCCESS");
            }
            else
            {
                Console.WriteLine("FAILED -- Cleaning Up");
                DeleteStack(stackId);
            }

            return(succeeded ? 0 : 1);
        }
Example #4
0
 public BuildStack(BuildVersion build) : base(build)
 {
 }
Example #5
0
        static int DoBuild(ParsedOpts args)
        {
            DateTime startTime = DateTime.Now;

            List <Revision> log    = GetMasterLog();
            string          commit = args["commit"].Value ?? log[0].Commit;

            Console.WriteLine(
                "Building and uploading for commit {0}...",
                commit
                );

            BuildVersion    lastVersion = GetLastVersion();
            List <Revision> changes     = GetDelta(log, commit, lastVersion.Commit);

            if (changes == null)
            {
                Console.WriteLine(
                    "Cannot find commit {0} in the log; aborting!",
                    commit
                    );
                return(2);
            }

            if (changes.Count > 0)
            {
                Console.WriteLine("Commits since the last build:");
                PrintChangeLog(changes);
            }
            else if (!args["force"].Flag)
            {
                Console.WriteLine(
                    "Latest build is for this commit, nothing to do."
                    );
                return(0);
            }

            if (!Confirm())
            {
                Console.WriteLine("Aborting.");
                return(3);
            }

            DateTime now       = DateTime.UtcNow;
            string   buildDate = String.Format(
                "{0:D4}{1:D2}{2:D2}",
                now.Year,
                now.Month,
                now.Day
                );
            string buildTime = String.Format(
                "{0:D2}{1:D2}{2:D2}Z",
                now.Hour,
                now.Minute,
                now.Second
                );
            var version = new BuildVersion
            {
                BuildDate = buildDate,
                BuildTime = buildTime,
                Commit    = commit
            };

            Console.WriteLine("Building {0}", version);
            string stackId   = CreateStack(new BuildStack(version));
            bool   succeeded = WaitForStackCreated(stackId);

            DeleteStack(stackId);
            Console.WriteLine("BUILD {0}", succeeded ? "SUCCESS" : "FAILED");
            return(succeeded ? 0 : 1);
        }