forked from nishantdania/nodejs-docker-jenkins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
33 lines (33 loc) · 853 Bytes
/
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
node {
try {
stage('Checkout') {
checkout scm
}
stage('Environment') {
sh 'git --version'
echo "Branch: ${env.BRANCH_NAME}"
sh 'docker -v'
sh 'printenv'
}
stage('Build'){
if(env.BRANCH_NAME == 'master'){
sh 'docker build -t app --no-cache .'
sh 'docker tag app chandankas/nodetest'
sh 'docker login --username=chandanka --password=ekhfkefekhih@92139329'
sh 'docker push chandanka/nodetest'
}
}
stage('Deploy'){
if(env.BRANCH_NAME == 'master'){
sh 'docker pull chandanka/nodetest'
sh 'docker run -d -p 8090:8090 --name app chandanka/nodetest:latest'
sh 'docker stop app'
sh 'docker rmi -f $(docker images -a -q)'
sh 'docker rm -f $(docker ps -a -q)'
}
}
}
catch (err) {
throw err
}
}