-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
51 lines (48 loc) · 1.72 KB
/
Jenkinsfile
File metadata and controls
51 lines (48 loc) · 1.72 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
pipeline {
agent any
stages {
stage('Clone Repos') {
steps {
checkout([
$class: 'GitSCM',
branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [
[$class: 'SubmoduleOption', recursiveSubmodules: true, trackingSubmodules: true]
],
userRemoteConfigs: [[
url: 'https://github.com/pratyushsingha/Threads.git'
]]
])
}
}
stage('Docker Compose Build && Push') {
steps {
echo 'Building the Docker Image...'
withCredentials([
usernamePassword(
credentialsId: 'dockerHubCred',
passwordVariable: 'dockerHubPass',
usernameVariable: 'dockerHubUser'
)
]) {
sh 'docker login -u $dockerHubUser -p $dockerHubPass'
sh 'docker compose build'
echo 'Pushing Docker Images to Docker Hub...'
sh 'docker push pratyush044/threads_client:latest'
sh 'docker push pratyush044/threads_server:latest'
}
}
}
stage('Deploy') {
steps {
echo 'Deploy on ec2...'
dir('/var/lib/jenkins/workspace/Threads') {
sh 'docker compose down --remove-orphans'
sh 'docker compose pull'
sh 'docker compose up -d --remove-orphans'
}
}
}
}
}