forked from LondheShubham153/node-todo-cicd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
35 lines (34 loc) · 1.09 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"}
stages{
stage("Code Clone"){
steps{
echo "Code Clone Stage"
git url: "https://github.com/Vishal-Kumar-CSE/node-todo-cicd.git", branch: "master"
}
}
stage('Image Build'){
steps{
sh "docker build --no-cache -t node-app ."
}
}
stage("Push to Dockerhub"){
steps{
withCredentials([usernamePassword(
credentialsId:"dockerHubCreds",
usernameVariable:"dockerHubUser",
passwordVariable: "dockerHubPass")]) {
// Your code here
sh "docker login -u ${env.dockerHubUser} -p ${env.dockerHubPass}"
sh "docker image tag node-app:latest ${env.dockerHubUser}/node-app"
sh "docker push ${env.dockerHubUser}/node-app:latest"
}
}
}
stage('Deploy'){
steps{
sh "docker compose down && docker compose up -d"
}
}
}
}