-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
62 lines (60 loc) · 2.31 KB
/
Jenkinsfile
File metadata and controls
62 lines (60 loc) · 2.31 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
52
53
54
55
56
57
58
59
60
61
62
pipeline {
agent any
stages {
stage('Cloning Git repository') {
steps {
cleanWs()
git branch:'main',credentialsId:'github',url: 'https://github.com/Jomin728/Bucket-Nodejs.git'
}
}
stage('Build Docker Image')
{
steps {
sh "pwd"
sh "docker login --username='jomin729' --password='Jomin729@'"
dir('server') {
sh "pwd"
sh "ls"
sh "docker build --no-cache -t jomin729/nodeservice ."
}
}
}
stage('Push Image to Docker Hub')
{
steps {
sh "docker push jomin729/nodeservice"
}
}
stage('Copy kube yaml Configurations')
{
steps{
sh "chmod 400 'jomin1.pem'"
sh "scp -v -o StrictHostKeyChecking=no -i 'jomin1.pem' server/server-deployment.yaml ubuntu@ec2-3-83-241-86.compute-1.amazonaws.com:~/."
sh "scp -v -o StrictHostKeyChecking=no -i 'jomin1.pem' server/server-service.yaml ubuntu@ec2-3-83-241-86.compute-1.amazonaws.com:~/."
sh "scp -v -o StrictHostKeyChecking=no -i 'jomin1.pem' server/ingress-controller.yaml ubuntu@ec2-3-83-241-86.compute-1.amazonaws.com:~/."
}
}
stage('SSH into master node')
{
steps{
script {
sshagent(credentials : ['masternode']) {
sh "echo pwd"
sh "ssh -t -t ubuntu@ec2-3-83-241-86.compute-1.amazonaws.com 'echo pwd && kubectl get pods && kubectl delete deployment node-api && kubectl apply -f server-deployment.yaml && kubectl apply -f server-service.yaml && kubectl apply -f ingress-controller.yaml'"
}
}
}
}
}
post {
// Clean after build
always {
cleanWs(cleanWhenNotBuilt: false,
deleteDirs: true,
disableDeferredWipeout: true,
notFailBuild: true,
patterns: [[pattern: '.gitignore', type: 'INCLUDE'],
[pattern: '.propsfile', type: 'EXCLUDE']])
}
}
}