def stage(configuration, recipes, branch="develop"): """ Create or synchronise stage environment on branch """ # Check workspace existence if not workspace.exists(configuration, "stage", branch): f_utils.puts(f_colors.green("create workspace for %s" % branch)) # Create workspace if not workspace.create(configuration, "stage", branch): f_utils.puts( f_colors.red("unable to create workspace for %s" % branch)) return unstage(configuration, branch) f_utils.puts(f_colors.green("workspace for %s branch created" % branch)) # Clone repository if not repository.clone(configuration, "stage", branch): f_utils.puts( f_colors.red("unable to clone %s for %s" % (configuration["project"]["repository"], branch))) return unstage(configuration, branch) f_utils.puts(f_colors.green("workspace for %s branch created" % branch)) # Install domain # Run recipe if not baker.bake(configuration, recipes, "stage", branch): f_utils.puts( f_colors.red("can not install configuration for %s" % branch)) return unstage(configuration, branch) f_utils.puts( f_colors.green("configuration installed for %s created" % branch)) return f_utils.puts( f_colors.green( "http://%s" % utils.get_domain_filename(configuration, "stage", branch))) else: f_utils.puts("synchronize repository for %s" % branch) if repository.synchronize(configuration, "stage", branch): f_utils.puts(f_colors.green("%s synchronized" % branch)) return f_utils.puts( f_colors.green( "http://%s" % utils.get_domain_filename(configuration, "stage", branch))) else: f_utils.puts(f_colors.red("can not synchronize %s" % branch)) return False
def stage(configuration, recipes, branch="develop"): """ Create or synchronise stage environment on branch """ # Check workspace existence if not workspace.exists(configuration, "stage", branch): f_utils.puts(f_colors.green("create workspace for %s" % branch)) # Create workspace if not workspace.create(configuration, "stage", branch): f_utils.puts(f_colors.red("unable to create workspace for %s" % branch)) return unstage(configuration, branch) f_utils.puts(f_colors.green("workspace for %s branch created" % branch)) # Clone repository if not repository.clone(configuration, "stage", branch): f_utils.puts(f_colors.red("unable to clone %s for %s" % (configuration["project"]["repository"], branch))) return unstage(configuration, branch) f_utils.puts(f_colors.green("workspace for %s branch created" % branch)) # Install domain # Run recipe if not baker.bake(configuration, recipes, "stage", branch): f_utils.puts(f_colors.red("can not install configuration for %s" % branch)) return unstage(configuration, branch) f_utils.puts(f_colors.green("configuration installed for %s created" % branch)) return f_utils.puts(f_colors.green("http://%s" % utils.get_domain_filename(configuration, "stage", branch))) else: f_utils.puts("synchronize repository for %s" % branch) if repository.synchronize(configuration, "stage", branch): f_utils.puts(f_colors.green("%s synchronized" % branch)) return f_utils.puts(f_colors.green("http://%s" % utils.get_domain_filename(configuration, "stage", branch))) else: f_utils.puts(f_colors.red("can not synchronize %s" % branch)) return False
def synchronize(configuration, env, branch="develop"): """ Synchronize Synchronize repository - configuration - env - branch (develop) """ # Go to correct branch checkout(branch) # Push commits push(branch) # Pull commits if workspace.exists(configuration, env, branch) and exists(configuration, env, branch): pull(configuration, env, branch) return True else: output("unable to pull %s" % branch) return False