-
Notifications
You must be signed in to change notification settings - Fork 4.6k
/
Jenkinsfile
35 lines (34 loc) · 1.13 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
pipeline{
agent { label 'dev-server' }
stages{
stage("Code Clone"){
steps{
echo "Code Clone Stage"
git url: "https://github.com/LondheShubham153/node-todo-cicd.git", branch: "master"
}
}
stage("Code Build & Test"){
steps{
echo "Code Build Stage"
sh "docker build -t node-app ."
}
}
stage("Push To DockerHub"){
steps{
withCredentials([usernamePassword(
credentialsId:"dockerHubCreds",
usernameVariable:"dockerHubUser",
passwordVariable:"dockerHubPass")]){
sh 'echo $dockerHubPass | docker login -u $dockerHubUser --password-stdin'
sh "docker image tag node-app:latest ${env.dockerHubUser}/node-app:latest"
sh "docker push ${env.dockerHubUser}/node-app:latest"
}
}
}
stage("Deploy"){
steps{
sh "docker compose down && docker compose up -d --build"
}
}
}
}