-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsFile
More file actions
46 lines (44 loc) · 1.42 KB
/
Copy pathJenkinsFile
File metadata and controls
46 lines (44 loc) · 1.42 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
pipeline {
agent any
stages {
stage('Clone Project') {
steps {
git 'https://github.com/HargovindArora/DevOpsCalculator'
}
}
stage('Build') {
steps {
sh 'cd app/ && pip3 install -r requirements.txt'
}
}
stage('Test') {
steps {
sh 'cd app/ && python3 -m pytest'
}
}
stage('Build Docker Images') {
steps {
sh 'docker build -f "app/Dockerfile" -t hargovind04/spe_flask:latest .'
sh 'docker build -f "nginx/Dockerfile" -t hargovind04/spe_nginx:latest .'
}
}
stage('Publish Docker Images') {
steps {
withDockerRegistry([ credentialsId: "DockerID", url: "" ]) {
sh 'docker push hargovind04/spe_flask:latest'
sh 'docker push hargovind04/spe_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
}
}
}
}