diff --git a/Jenkinsfile b/Jenkinsfile index c4b3931..810b50d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -12,7 +12,6 @@ node { credentialsId: "jenkins-github-access-token" ]) sh 'mv ./bin/* ../bin/.' } - sh 'rm -rf tmp' stage 'Setting build context' @@ -44,6 +43,10 @@ node { sh "rm -f ./debug" handleError(message) } + + stage 'Start' + + sh 'bin/start.sh' stage 'Tests' @@ -54,8 +57,14 @@ node { def message = "BUILD ERROR: There was a problem building ${imagename}:${tag}. \n\n ${error_details}" sh "rm -f ./debug" handleError(message) + } finally { + sh 'bin/stop.sh' } + stage 'Stop' + + sh 'bin/stop.sh' + stage 'Push' docker.withRegistry('https://registry.hub.docker.com/', "dockerhub-$maintainer") { @@ -66,6 +75,10 @@ node { stage 'Notify' slackSend color: 'good', message: "$maintainer/$imagename:$tag pushed to DockerHub" + + stage 'Cleanup' + + sh 'rm -rf tmp' } diff --git a/tests/running.bats b/tests/running.bats new file mode 100644 index 0000000..0263d88 --- /dev/null +++ b/tests/running.bats @@ -0,0 +1,13 @@ +#!/usr/bin/env bats + +load ../common + +# Assumes process is running + +@test "MySQL user running process" { + docker exec -i $imagename ps -u mysql +} + +@test "Creates root account and database" { + docker exec -i $imagename mysql -u root --password="123321" -e 'show tables' registry +} \ No newline at end of file