forked from ajitfawade/node-todo-cicd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
37 lines (31 loc) · 1.07 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
pipeline {
agent { label 'dev' }
stages {
stage ('Code') {
steps {
git url: 'https://github.com/ajitfawade/node-todo-cicd.git', branch: 'master'
}
}
stage ('Build & Test') {
steps {
echo 'Build & Test'
sh 'docker build . -t ajitfawade14/node-todo-app:latest'
}
}
stage ('Login & Push Image') {
steps {
echo 'Logging in to docker hub and pushing image'
withCredentials([usernamePassword('credentialsId':'dockerhub', passwordVariable: 'dockerHubPassword', usernameVariable: 'dockerHubUser')]){
sh "docker login -u ${env.dockerHubUser} -p ${env.dockerHubPassword}"
sh "docker image push ajitfawade14/node-todo-app:latest"
}
}
}
stage ('Deploy') {
steps {
echo 'Deploying'
sh 'docker-compose down && docker-compose up -d'
}
}
}
}