-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
55 lines (36 loc) · 1.23 KB
/
Jenkinsfile
File metadata and controls
55 lines (36 loc) · 1.23 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
pipeline {
agent { label 'jenkins-agent' }
stages{
stage("Code"){
steps{
git url: 'https://github.com/vansh1999/markethub.git' , branch: 'main'
echo "Code received successfully from github +++"
}
}
stage("Build and Test"){
steps{
sh 'docker build . -t markethub'
}
}
// stage("login in dockerhub"){
// steps{
// withCredentials([usernamePassword(credentialsID: 'markethub-pass' , passwordVariable: 'dockerHubPassword' , usernameVariable: 'dockerHubUsername' )]){
// sh 'docker login -u ${env.dockerHubUsername} -p ${dockerHubPassword}''
// }
// }
// }
stage("Deploy"){
steps{
sh '''
CONTAINER_ID=$(docker ps -q --filter publish=8000)
if [ -n "$CONTAINER_ID" ]; then
docker stop $CONTAINER_ID
else
echo "No container is using port 8000"
fi
docker run -d -p 8000:8000 markethub:latest
'''
}
}
}
}