-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkins
52 lines (35 loc) · 1.59 KB
/
Jenkins
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
node{
stage('Git Checkout'){
git branch: 'main', url: 'https://github.com/99North/Kubernetes-Project-Jen-Ans-K8s.git'
}
stage('Sending Docker file to Ansible over SSH'){
sshagent(['ansible-ubuntu']) {
sh 'ssh -o StrictHostKeyChecking=no ubuntu@172.31.66.61'
sh 'scp /var/lib/jenkins/workspace/pipeline-demo/* ubuntu@172.31.66.61:/home/ubuntu'
}
}
stage('Docker Build Image'){
sshagent(['ansible-ubuntu']) {
sh 'ssh -o StrictHostKeyChecking=no ubuntu@172.31.66.61 cd /home/ubuntu'
sh 'ssh -o StrictHostKeyChecking=no ubuntu@172.31.66.61 docker image build -t $JOB_NAME:v1.$BUILD_ID .'
}
}
stage('Docker Image Tag'){
sshagent(['ansible-ubuntu']){
sh 'ssh -o StrictHostKeyChecking=no ubuntu@172.31.66.61 docker image tag $JOB_NAME:v1.$BUILD_ID debiprasad007/$JOB_NAME:latest'
}
}
stage('Copy Files frm Ansible to Kubernetes'){
sshagent(['kubernetes-key']) {
sh 'ssh -o StrictHostKeyChecking=no ubuntu@172.31.74.60'
sh 'scp /var/lib/jenkins/workspace/pipeline-demo/* ubuntu@172.31.74.60:/home/ubuntu'
}
}
stage('Kbernetes Deployement Using Ansible'){
sshagent(['ansible-ubuntu']){
sh 'ssh -o StrictHostKeyChecking=no ubuntu@172.31.66.61 cd /home/ubuntu'
sh 'ssh -o StrictHostKeyChecking=no ubuntu@172.31.66.61 ansible -m ping node'
sh 'ssh -o StrictHostKeyChecking=no ubuntu@172.31.66.61 ansible-playbook ansible.yaml'
}
}
}