コード例 #1
0
def _git_deploy(release, skip_tests):
    starting_branch = utils.branch()
    print(green("Deploying from git branch '%s'" % starting_branch))
    # Ideally, tests would run on the version you are deploying exactly.
    # There is no easy way to require that without allowing users to go
    # through the entire tagging process before failing tests.
    if not skip_tests and testing.test():
        abort(red("Unit tests did not pass -- must fix before deploying"))

    local('git push %(master_remote)s' % env, capture=True)
    deploy.release.make_release(release)

    require('pretty_release')
    require('path')
    require('hosts')

    print(green("Deploying version %s" % env.pretty_release))
    put(
        os.path.join(os.path.abspath(os.path.dirname(__file__)), '..', 'files',
                     'ssh_config'), '.ssh/config')

    deployed = False
    hard_reset = False
    deployed_versions = {}
    deploy.release.bootstrap_release_folders()
    for release_path in env.release_paths:
        with cd(os.path.join(env.path, env.releases_root, release_path)):
            deployed_versions[run('git describe')] = release_path
    print(
        green("The host '%s' currently has the revisions: %s" %
              (env.host, deployed_versions)))
    if env.pretty_release not in deployed_versions:
        env.release_path = os.path.join(
            env.path, env.releases_root,
            deploy.release.alternative_release_path())
        with cd(env.release_path):
            run('git fetch %(master_remote)s' % env, forward_agent=True)
            run('git reset --hard %(release)s' % env)
        deploy.cron.conditional_install_crontab(env.release_path, env.crontab,
                                                env.deploy_user)
        deployed = True
    else:
        warn(red("%(pretty_release)s is already deployed" % env))
        env.release_path = os.path.join(env.path, env.releases_root,
                                        deployed_versions[env.pretty_release])
    with cd(env.release_path):
        run('git submodule update --init --recursive', forward_agent=True)
    hard_reset = deploy.packages.install_requirements(deployed)
    deploy.utils.run_extra_deploy_tasks(deployed)
    local('git checkout %s' % starting_branch, capture=True)
    chmod(os.path.join(env.path, env.releases_root), 'g+w', use_sudo=True)
    return deployed, hard_reset
コード例 #2
0
ファイル: types.py プロジェクト: nkeilar/ops
def _git_deploy(release, skip_tests):
    starting_branch = utils.branch()
    print(green("Deploying from git branch '%s'" % starting_branch))
    # Ideally, tests would run on the version you are deploying exactly.
    # There is no easy way to require that without allowing users to go
    # through the entire tagging process before failing tests.
    if not skip_tests and testing.test():
        abort(red("Unit tests did not pass -- must fix before deploying"))

    #local('git push %(master_remote)s' % env, capture=True)
    #buedafab.deploy.release.make_release(release)
    make_release(release)

    require('pretty_release')
    require('path')
    require('hosts')

    print(green("Deploying version %s" % env.pretty_release))
    put(os.path.join(os.path.abspath(os.path.dirname(__file__)),
            '..', 'files', 'ssh_config'), '.ssh/config')

    deployed = False
    hard_reset = False
    deployed_versions = {}
    bootstrap_release_folders()
    for release_path in env.release_paths:
        with cd(os.path.join(env.path, env.releases_root, release_path)):
            deployed_versions[run('git describe')] = release_path
    print(green("The host '%s' currently has the revisions: %s"
        % (env.host, deployed_versions)))
    if env.pretty_release not in deployed_versions:
        env.release_path = os.path.join(env.path, env.releases_root,
                alternative_release_path())
        with cd(env.release_path):
            run('git fetch %(master_remote)s --tag' % env, forward_agent=False)
            run('git fetch %(master_remote)s' % env, forward_agent=False)
            run("git reset --hard %(release)s" % env)
        cron.conditional_install_crontab(env.release_path, env.crontab,
                env.deploy_user)
        deployed = True
    else:
        warn(red("%(pretty_release)s is already deployed" % env))
        env.release_path = os.path.join(env.path, env.releases_root,
                deployed_versions[env.pretty_release])
    with cd(env.release_path):
        run('git submodule update --init --recursive', forward_agent=False)
    hard_reset = packages.install_requirements(deployed)
    run_extra_deploy_tasks(deployed)
    local('git checkout %s' % starting_branch, capture=True)
    chmod(os.path.join(env.path, env.releases_root), 'g+w', use_sudo=True)
    return deployed, hard_reset
コード例 #3
0
ファイル: packages.py プロジェクト: xuweicn1/ops
def _install_private_package(package, scm=None, release=None):
    env.scratch_path = os.path.join('/tmp', '%s-%s' % (package, env.time_now))
    archive_path = '%s.tar.gz' % env.scratch_path

    if not scm:
        require('s3_key')
        env.s3_key.key = '%s.tar.gz' % package
        env.s3_key.get_contents_to_filename(archive_path)
    else:
        if 'release' not in env:
            env.release = release
        release = release or 'HEAD'
        if 'pretty_release' in env:
            original_pretty_release = env.pretty_release
        else:
            original_pretty_release = None
        if 'archive' in env:
            original_archive = env.archive
        else:
            original_archive = None
        with settings(unit=package, scm=scm, release=release):
            if not os.path.exists(env.scratch_path):
                local('git clone %(scm)s %(scratch_path)s' % env)
            deploy.utils.make_archive()
            local('mv %s %s' %
                  (os.path.join(env.scratch_path, env.archive), archive_path))
        if original_pretty_release:
            env.pretty_release = original_pretty_release
        if original_archive:
            env.archive = original_archive
    put(archive_path, '/tmp')
    if env.virtualenv is not None:
        require('release_path')
        require('path')
        with cd(env.release_path):
            run('%s -E %s -s %s' %
                (env.pip_install_command, env.virtualenv, archive_path))
    else:
        run('%s -s %s' % (env.pip_install_command, archive_path))
コード例 #4
0
ファイル: packages.py プロジェクト: alexmerser/ops
def _install_private_package(package, scm=None, release=None):
    env.scratch_path = os.path.join('/tmp', '%s-%s' % (package, env.time_now))
    archive_path = '%s.tar.gz' % env.scratch_path

    if not scm:
        require('s3_key')
        env.s3_key.key = '%s.tar.gz' % package
        env.s3_key.get_contents_to_filename(archive_path)
    else:
        if 'release' not in env:
            env.release = release
        release = release or 'HEAD'
        if 'pretty_release' in env:
            original_pretty_release = env.pretty_release
        else:
            original_pretty_release = None
        if 'archive' in env:
            original_archive = env.archive
        else:
            original_archive = None
        with settings(unit=package, scm=scm, release=release):
            if not os.path.exists(env.scratch_path):
                local('git clone %(scm)s %(scratch_path)s' % env)
            deploy.utils.make_archive()
            local('mv %s %s' % (os.path.join(env.scratch_path, env.archive),
                    archive_path))
        if original_pretty_release:
            env.pretty_release = original_pretty_release
        if original_archive:
            env.archive = original_archive
    put(archive_path, '/tmp')
    if env.virtualenv is not None:
        require('release_path')
        require('path')
        with cd(env.release_path):
            run('%s -E %s -s %s'
                    % (env.pip_install_command, env.virtualenv, archive_path))
    else:
        run('%s -s %s' % (env.pip_install_command, archive_path))