check-migrations.sh 2.35 KB
Newer Older
John Jarvis committed
1 2
#!/usr/bin/env bash
set -x
3
set -e
John Jarvis committed
4

5
if [[ -z $WORKSPACE ]]; then
John Jarvis committed
6 7 8 9 10 11 12
    echo "Environment incorrect for this wrapper script"
    env
    exit 1
fi


env
13
cd "$WORKSPACE/edx-platform"
John Jarvis committed
14 15 16 17 18 19 20 21

# install requirements
# These requirements will be installed into the shinginpanda
# virtualenv on the jenkins server and are necessary to run
# run migrations locally

pip install --exists-action w -r requirements/edx/pre.txt
pip install --exists-action w -r requirements/edx/base.txt
22
if [[ -f requirements/edx/post.txt ]]; then
23 24
  pip install --exists-action w -r requirements/edx/post.txt
fi
25
if [[ -f requirements/edx/repo.txt ]]; then
26 27
  pip install --exists-action w -r requirements/edx/repo.txt
fi
John Jarvis committed
28
pip install --exists-action w -r requirements/edx/github.txt
29
if [[ -f requirements/edx/local.txt ]]; then
30 31
  pip install --exists-action w -r requirements/edx/local.txt
fi
32
pip install --exists-action w -r requirements/edx/edx-private.txt
John Jarvis committed
33

34
cd "$WORKSPACE/configuration/playbooks/edx-east"
John Jarvis committed
35

36 37
if [[ -f ${WORKSPACE}/configuration-secure/ansible/vars/${deployment}.yml ]]; then
    extra_var_args+=" -e@${WORKSPACE}/configuration-secure/ansible/vars/${deployment}.yml"
John Jarvis committed
38 39
fi

John Jarvis committed
40
if [[ $db_dry_run == "false" ]]; then
41
    # Set this to an empty string if db_dry_run is
John Jarvis committed
42
    # not set.  By default the db_dry_run var is
43
    # set to --list
John Jarvis committed
44

John Jarvis committed
45 46 47
    extra_var_args+=" -e db_dry_run=''"
fi

48 49 50 51 52 53 54 55
if [[ -f ${WORKSPACE}/configuration-secure/ansible/vars/${environment}-${deployment}.yml ]]; then
    extra_var_args+=" -e@${WORKSPACE}/configuration-secure/ansible/vars/${environment}-${deployment}.yml"
fi

for extra_var in $extra_vars; do
    extra_var_args+=" -e@${WORKSPACE}/configuration-secure/ansible/vars/$extra_var"
done

John Jarvis committed
56 57 58
extra_var_args+=" -e edxapp_app_dir=${WORKSPACE}"
extra_var_args+=" -e edxapp_code_dir=${WORKSPACE}/edx-platform"
extra_var_args+=" -e edxapp_user=jenkins"
59
extra_var_args+=" -e EDXAPP_CFG_DIR=${WORKSPACE}"
60
extra_var_args+=" -e THEMES_CODE_DIR=${WORKSPACE}"
John Jarvis committed
61 62 63

# Run migrations and replace literal '\n' with actual newlines to make the output
# easier to read
64 65
# We use the edxapp_cfg tag so that the edxapp role will generate config files but
# nothing else.  The actual migrate commands are then run from the playbook.
John Jarvis committed
66

67
ansible-playbook -v -c local $extra_var_args --tags edxapp_cfg -i localhost, -s -U jenkins edxapp_migrate.yml | sed 's/\\n/\n/g'
68 69 70

#We don't care about the exit status of the `sed`
exit ${PIPESTATUS[0]}