-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
90 lines (87 loc) · 2.94 KB
/
Jenkinsfile
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
pipeline {
agent any
// tools {
// jdk 'jdk17'
// nodejs 'node:16.17.0'
// }
environment {
SCANNER_HOME = tool 'sonar-scanner'
CURRENT_WORKSPACE = pwd()
}
stages {
stage('clean workspace') {
steps {
cleanWs()
}
}
stage('Checkout from Git') {
steps {
git branch: 'main', url: 'https://github.com/amjedsaleel/m3-mobiles'
}
}
stage("Sonarqube Analysis") {
steps {
script {
def scannerHome = tool 'sonar-scanner';
withSonarQubeEnv("sonarqube-sever") {
sh "${scannerHome}/bin/sonar-scanner"
}
}
}
}
stage("Quality Gate") {
steps {
timeout(time: 1, unit: 'HOURS') {
waitForQualityGate abortPipeline: true, credentialsId: 'sonarqube-tocken'
}
}
}
stage('Install Dependencies') {
steps {
sh 'python3 -m venv venv'
sh '${CURRENT_WORKSPACE}/venv/bin/pip install -r requirements.txt'
}
}
stage('OWASP FS SCAN') {
steps {
dependencyCheck additionalArguments: '--scan ./ --disableYarnAudit --disableNodeAudit', odcInstallation: 'DP-check'
dependencyCheckPublisher pattern: '**/dependency-check-report.xml'
}
}
stage('TRIVY FS SCAN') {
steps {
sh 'trivy fs --format template --template "@/usr/local/share/trivy/templates/html.tpl" --ignore-unfixed -o trivy-fs-report.html .'
}
}
stage('Docker build') {
steps {
sh 'docker build -t amjedsaleel/m3-mobile:${BUILD_NUMBER} .'
}
}
stage('Trivy image scan') {
steps {
sh 'trivy image --format template --template "@/usr/local/share/trivy/templates/html.tpl" --ignore-unfixed -o trivy-image-report.html amjedsaleel/m3-mobile:${BUILD_NUMBER}'
}
}
stage('Push Image') {
steps {
withCredentials([usernamePassword(credentialsId: 'dockerhub', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')]) {
sh 'docker login -u $USERNAME -p $PASSWORD'
}
sh 'docker push amjedsaleel/m3-mobile:${BUILD_NUMBER}'
sh 'docker logout'
}
}
}
post {
always {
emailext subject: '$JOB_NAME',
body: '$DEFAULT_CONTENT',
replyTo: '[email protected]',
attachLog: true,
to: '[email protected]',
mimeType: 'text/html',
attachmentsPattern: 'trivy-fs-report.html,trivy-image-report.html'
}
}
}