-
Notifications
You must be signed in to change notification settings - Fork 59
/
Jenkinsfile
44 lines (44 loc) · 1.54 KB
/
Jenkinsfile
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
32
33
34
35
36
37
38
39
40
41
42
43
44
pipeline {
agent any
stages {
stage('Tests') {
steps {
// script {
// docker.image('node:10-stretch').inside { c ->
echo 'Building..'
sh 'npm install'
echo 'Testing..'
sh 'npm test'
// sh "docker logs ${c.id}"
// }
// }
}
}
stage('Build and push docker image') {
steps {
script {
def dockerImage = docker.build("antonml/node-demo:master")
docker.withRegistry('', 'demo-docker') {
dockerImage.push('master')
}
}
}
}
stage('Deploy to remote docker host') {
environment {
DOCKER_HOST_CREDENTIALS = credentials('demo-docker')
}
steps {
script {
// sh 'docker login -u $DOCKER_HOST_CREDENTIALS_USR -p $DOCKER_HOST_CREDENTIALS_PSW 127.0.0.1:2375'
sh 'docker pull antonml/node-demo:master'
sh 'docker stop node-demo'
sh 'docker rm node-demo'
sh 'docker rmi antonml/node-demo:current'
sh 'docker tag antonml/node-demo:master antonml/node-demo:current'
sh 'docker run -d --name node-demo -p 80:3000 antonml/node-demo:current'
}
}
}
}
}