forked from Intellipaat-Training/Shark-Secure-Pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Stage3
45 lines (41 loc) · 1.73 KB
/
Stage3
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
pipeline {
agent none
environment {
DOCKERHUB_CREDENTIALS = credentials('5acd5eb3-e919-40bd-97fe-4d057700d975')
}
stages {
stage('Git') {
agent {
label 'Kmaster'
}
steps {
sh 'git clone https://github.com/Intellipaat-Training/Shark-Secure-Pipeline.git'
}
}
stage('Docker') {
agent {
label 'Kmaster'
}
steps {
sh 'sudo apt install docker.io -y'
sh 'sudo docker build /home/ubuntu/jenkins/workspace/Deployment/Shark-Secure-Pipeline/. -t docker6767/sharkproduct'
sh 'sudo curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sudo sh -s -- -b /usr/local/bin'
sh 'sudo trivy image docker6767/sharkproduct --scanners vuln > image_report.txt'
sh 'sudo echo $DOCKERHUB_CREDENTIALS_PSW | sudo docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin'
sh 'sudo docker push docker6767/sharkproduct'
}
}
stage('K8s') {
agent {
label 'Kmaster'
}
steps {
// Install kube-bench
sh 'sudo docker run --rm -v `pwd`:/host docker.io/aquasec/kube-bench:latest install'
sh 'sudo ./kube-bench > kubernetesbench.txt'
sh 'kubectl apply -f /home/ubuntu/jenkins/workspace/Deployment/Shark-Secure-Pipeline/deploy.yaml'
sh 'kubectl apply -f /home/ubuntu/jenkins/workspace/Deployment/Shark-Secure-Pipeline/svc.yaml'
}
}
}
}