Files

30 lines
896 B
Groovy

node {
def commit_id
stage('Preparation') {
checkout scm
commit_id = sh(returnStdout: true, script: "git log -n 1 --pretty=format:'%h'").trim()
}
stage('Test NPM') {
docker.image('node:8').inside {
sh 'npm install --only=dev'
sh 'npm test'
}
}
stage('Test with a DB') {
docker.image('mysql:8-oracle').withRun('-e MYSQL_ALLOW_EMPTY_PASSWORD=yes --rm') { mdb ->
docker.image('mysql:8-oracle').inside("--link ${mdb.id}:db") {
/* Wait until mysql service is up */
sh 'while ! mysqladmin ping -hdb --silent; do sleep 1; done'
}
docker.image('node:8').inside("--link ${mdb.id}:mysql") {
/*
* Run some tests which require MySQL, and assume that it is
* available on the host name `db`
*/
sh 'npm install --only=dev'
sh 'npm test'
}
}
}
}