forked from LondheShubham153/django-notes-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
48 lines (41 loc) · 1.33 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
38
39
40
41
42
43
44
45
46
47
48
pipeline{
agent {
node {
label"dev"
}
}
stages{
stage("Clone Code"){
steps{
git url:"https://github.com/pratham-mesh/django-notes-app-jenkins.git",branch:"main"
echo "Jenkins file is in sync with pipeline"
}
}
stage("Build & Test"){
steps{
sh "docker build . -t notes-app-jenkins:latest"
}
}
stage("Push to docker hub"){
steps{
withCredentials(
[usernamePassword(
credentialsId:"docker-creds",
passwordVariable:"dockerHubPass",
usernameVariable:"dockerHubuser"
)
]
){
sh "docker image tag notes-app-jenkins:latest ${env.dockerHubuser}/notes-app-jenkins:latest"
sh "docker login -u ${env.dockerHubuser} -p ${env.dockerHubPass}"
sh "docker push ${env.dockerHubuser}/notes-app-jenkins:latest"
}
}
}
stage("Deploy"){
steps{
sh "docker compose up -d"
}
}
}
}