Skip to content

Commit

Permalink
Fixed bug with DB and user cleanup on SKIP_MIGRATIONS
Browse files Browse the repository at this point in the history
Ready for release v1.2.1
  • Loading branch information
cpitkin committed Jan 23, 2018
1 parent d3e68e7 commit de523d7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased] - TBD

## [v1.2.1] - 1-23-2018
- Fixed a bug with the cleanup step trying to clean DB and users that weren't created if SKIP_MIGRATIONS = 'true'

## [v1.2.0] - 1-23-2018
- SKIP_MIGRATIONS parameter - You can skip running migrations during tests

Expand Down
18 changes: 10 additions & 8 deletions vars/rails.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ def call(body) {
echo "SQL: CREATE DATABASE IF NOT EXISTS ${env.MYSQL_DATABASE};"
sql connection: 'test_db', sql: "GRANT ALL ON ${env.MYSQL_DATABASE}.* TO \'${env.MYSQL_USER}\'@\'%\' IDENTIFIED BY \'${env.MYSQL_PASSWORD}\';"
echo "SQL: GRANT ALL ON ${env.MYSQL_DATABASE}.* TO \'${env.MYSQL_USER}\'@\'%\' IDENTIFIED BY \'**************\';"
currentBuild.result = 'SUCCESS'
}
currentBuild.result = 'SUCCESS'
}
} catch(Exception e) {
currentBuild.result = 'FAILURE'
Expand Down Expand Up @@ -192,13 +192,15 @@ def call(body) {
try {
stage('Clean Up') {
milestone label: 'Clean Up'
sql connection: 'test_db', sql: "DROP DATABASE IF EXISTS ${env.MYSQL_DATABASE};"
echo "SQL: DROP DATABASE IF EXISTS ${env.MYSQL_DATABASE};"
sql connection: 'test_db', sql: "REVOKE ALL PRIVILEGES, GRANT OPTION FROM ${env.MYSQL_USER}@'%';"
echo "SQL: REVOKE ALL PRIVILEGES, GRANT OPTION FROM ${env.MYSQL_USER}@'%';"
sql connection: 'test_db', sql: "DROP USER ${env.MYSQL_USER}@'%';"
echo "SQL: DROP USER ${env.MYSQL_USER}@'%';"
currentBuild.result = 'SUCCESS'
if (config.SKIP_MIGRATIONS == 'false') {
sql connection: 'test_db', sql: "DROP DATABASE IF EXISTS ${env.MYSQL_DATABASE};"
echo "SQL: DROP DATABASE IF EXISTS ${env.MYSQL_DATABASE};"
sql connection: 'test_db', sql: "REVOKE ALL PRIVILEGES, GRANT OPTION FROM ${env.MYSQL_USER}@'%';"
echo "SQL: REVOKE ALL PRIVILEGES, GRANT OPTION FROM ${env.MYSQL_USER}@'%';"
sql connection: 'test_db', sql: "DROP USER ${env.MYSQL_USER}@'%';"
echo "SQL: DROP USER ${env.MYSQL_USER}@'%';"
}
currentBuild.result = 'SUCCESS'
}
} catch(Exception e) {
currentBuild.result = 'FAILURE'
Expand Down
2 changes: 2 additions & 0 deletions vars/railsOtherBuildEnvs.groovy
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env groovy

@NonCPS
def call() {
if (env.OTHER_DEPLOY_ENVS) {
Expand Down

0 comments on commit de523d7

Please sign in to comment.