-
Notifications
You must be signed in to change notification settings - Fork 1
/
JenkinsPipeline
48 lines (46 loc) · 1.67 KB
/
JenkinsPipeline
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 any
stages {
stage('Clone Project') {
steps {
git 'https://github.com/HargovindArora/CheckUp-Ease'
}
}
stage('Build') {
steps {
sh 'cd api/ && pip3 install -r requirements.txt'
}
}
stage('Test') {
steps {
sh 'cd api/ && export FLASK_ENV=development && python3 -m pytest'
}
}
stage('Build Docker Images') {
steps {
sh 'docker build -f "api/Dockerfile" -t hargovind04/checkup_ease_backend:latest .'
sh 'docker build -f "frontend/Dockerfile" -t hargovind04/checkup_ease_frontend:latest .'
sh 'docker build -f "nginx/Dockerfile" -t hargovind04/checkup_ease_nginx:latest .'
}
}
stage('Publish Docker Images') {
steps {
withDockerRegistry([ credentialsId: "DockerID", url: "" ]) {
sh 'docker push hargovind04/checkup_ease_backend:latest'
sh 'docker push hargovind04/checkup_ease_frontend:latest'
sh 'docker push hargovind04/checkup_ease_nginx:latest'
}
}
}
stage('Clean Docker Images') {
steps {
sh 'docker rmi -f $(docker images -a -q)'
}
}
stage('Deploy and Run Image on Remote Server'){
steps {
ansiblePlaybook becomeUser: null, colorized: true, disableHostKeyChecking: true, installation: 'Ansible', inventory: 'hosts', playbook: 'playbook.yml', sudoUser: null
}
}
}
}