-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
48 lines (42 loc) · 1.3 KB
/
Copy pathJenkinsfile
File metadata and controls
48 lines (42 loc) · 1.3 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
pipeline {
agent any
environment {
SSH_CREDS = credentials('vm-ssh-credentials')
VM_IP = '192.168.56.101'
}
stages {
stage('Checkout') {
steps {
git branch: 'main', url: 'https://github.com/gabrielviegas/devops-observability-stack.git'
}
}
stage('Provision VM') {
steps {
dir('ansible/playbooks') {
sh 'ansible-playbook create_vm.yml'
}
}
}
stage('Configure Docker') {
steps {
dir('ansible/playbooks') {
sh "ansible-playbook -i ${VM_IP}, -u ubuntu --private-key $SSH_CREDS_KEY install_docker.yml"
}
}
}
stage('Deploy Stack') {
steps {
sshagent(['vm-ssh-credentials']) {
sh "scp -o StrictHostKeyChecking=no docker-compose-stack.yml prometheus/prometheus.yml ubuntu@${VM_IP}:~/"
sh "ssh -o StrictHostKeyChecking=no ubuntu@${VM_IP} 'docker compose -f docker-compose-stack.yml up -d'"
}
}
}
stage('Health Check') {
steps {
sleep 20
sh "curl -I http://${VM_IP}:3000"
}
}
}
}