forked from Ashfaque-9x/node-todo-labapp-cicd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
30 lines (29 loc) · 1 KB
/
Jenkinsfile
File metadata and controls
30 lines (29 loc) · 1 KB
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
pipeline {
agent { label 'DockerAgent' }
stages{
stage('code'){
steps {
git url: 'https://github.com/rubesh-git/node-todo-labapp-cicd.git', branch: 'main'
}
}
stage('Build and Test'){
steps {
sh 'docker build . -t rubeshj34/node-todo-labapp-cicd:latest'
}
}
stage('Login and Push Image'){
steps {
echo 'logging in to docker hub and pushing image..'
withCredentials([usernamePassword(credentialsId:'DockerHub',passwordVariable:'DockerHubPassword', usernameVariable:'DockerHubUsername')]) {
sh "docker login -u ${env.DockerHubUsername} -p ${env.DockerHubPassword}"
sh "docker push rubeshj34/node-todo-labapp-cicd:latest"
}
}
}
stage('Deploy'){
steps {
sh 'docker-compose down && docker-compose up -d'
}
}
}
}