-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile_v2
31 lines (31 loc) · 1.15 KB
/
Jenkinsfile_v2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
node {
def commit_id
stage('Preparation') {
checkout scm
sh "git rev-parse --short HEAD > .git/commit-id"
commit_id = readFile('.git/commit-id').trim()
}
stage('test') {
def myTestContainer = docker.image('node:4.6')
myTestContainer.pull()
myTestContainer.inside {
sh 'npm install --only=dev'
sh 'npm test'
}
}
stage('test with a DB') {
def mysql = docker.image('mysql').run("-e MYSQL_ALLOW_EMPTY_PASSWORD=yes")
def myTestContainer = docker.image('node:4.6')
myTestContainer.pull()
myTestContainer.inside("--link ${mysql.id}:mysql") { // using linking, mysql will be available at host: mysql, port: 3306
sh 'npm install --only=dev'
sh 'npm test'
}
mysql.stop()
}
stage('docker build/push') {
docker.withRegistry('https://index.docker.io/v1/', 'dockerhub') {
def app = docker.build("wardviaene/docker-nodejs-demo:${commit_id}", '.').push()
}
}
}