Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

Commit 7f7ea06

Browse files
committed
#52050 - Matomo deployment script fixes.
1 parent c832601 commit 7f7ea06

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

matomo/Matomo.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ def mysql_backup_db(db_name, build, fail_build=False, mysql_config='/etc/mysql/d
3030
def database_updates(repo, branch, build, www_root, application_directory, db_name):
3131
print "Applying database updates."
3232
with settings(warn_only=True):
33-
with cd("%s/%s_%s_%s/%s" % (www_root, repo, branch, application_directory)):
34-
if run("su -s /bin/bash www-data -c 'console core:update'").failed:
35-
print "Could not run database updates. Reverting database and aborting."
33+
with cd("%s/%s_%s_%s/%s" % (www_root, repo, branch, build, application_directory)):
34+
if sudo("su -s /bin/bash www-data -c './console core:update'").failed:
3635
execute(Revert._revert_db, repo, branch, build, db_name)
36+
raise SystemExit("###### Could not run database updates. Reverting database and aborting.")
3737

3838

3939
# Clear Matomo cache
@@ -42,8 +42,8 @@ def database_updates(repo, branch, build, www_root, application_directory, db_na
4242
def clear_cache(repo, branch, build, www_root, application_directory):
4343
print "Clearing cache."
4444
with settings(warn_only=True):
45-
with cd("%s/%s_%s_%s/%s" % (www_root, repo, branch, application_directory)):
46-
if run("su -s /bin/bash www-data -c 'console cache:clear'").failed:
45+
with cd("%s/%s_%s_%s/%s" % (www_root, repo, branch, build, application_directory)):
46+
if sudo("su -s /bin/bash www-data -c './console cache:clear'").failed:
4747
print "Could not clear the cache. Not failing the build though."
4848

4949

matomo/Revert.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ def mysql_revert_db(db_name, build, mysql_config='/etc/mysql/debian.cnf'):
2424
print "===> Waiting 5 seconds to let MySQL internals catch up"
2525
time.sleep(5)
2626
print "===> Restoring the database from backup"
27-
sudo("if [ -f /var/www/shared/dbbackups/%s_prior_to_%s.sql.gz ]; then zcat ~jenkins/dbbackups/%s_prior_to_%s.sql.gz | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' | mysql --defaults-file=%s -D %s; fi" % (db_name, build, db_name, build, mysql_config, db_name))
27+
sudo("if [ -f /var/www/shared/dbbackups/%s_prior_to_%s.sql.gz ]; then zcat /var/www/shared/dbbackups/%s_prior_to_%s.sql.gz | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' | sed -e 's/^SET @@SESSION.SQL_LOG_BIN/-- &/' | sed -e 's/^SET @@GLOBAL.GTID_PURGED=/-- &/' | mysql --defaults-file=%s -D %s; fi" % (db_name, build, db_name, build, mysql_config, db_name))

matomo/common

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../common

matomo/fabfile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def main(repo, repourl, build, branch, buildtype, keepbuilds=10, restartvarnish=
9595
execute(common.Utils.perform_client_deploy_hook, repo, branch, build, buildtype, config, stage='mid', build_hook_version="1", hosts=env.roledefs['app_all'])
9696
execute(common.Utils.perform_client_deploy_hook, repo, branch, build, buildtype, config, stage='mid-prim', build_hook_version="1", hosts=env.roledefs['app_primary'])
9797

98-
execute(Matomo.database_updates, repo, branch, build, www_root, application_directory)
98+
execute(Matomo.database_updates, repo, branch, build, www_root, application_directory, db_name)
9999

100100
# Adjust the live symlink now that all sites have been deployed. Bring them online after this has happened.
101101
if previous_build is not None:

0 commit comments

Comments
 (0)