-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
79 lines (74 loc) · 2.39 KB
/
Jenkinsfile
File metadata and controls
79 lines (74 loc) · 2.39 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
pipeline {
agent any
tools {
jdk 'jdk21'
maven 'maven3'
nodejs 'node'
}
environment {
SCANNER_HOME= tool 'sonar-scanner'
}
stages {
stage('Git Pull') {
steps {
git branch: 'development', credentialsId: 'git-cred-d', url: 'https://github.com/shumisoft/url-shortener-redirection-service'
}
}
stage('Maven Compile') {
steps {
sh 'mvn compile'
}
}
stage('Run Test') {
steps {
// sh 'mvn test'
echo 'Todo'
echo 'Skipping...'
}
}
stage('Trivy Vulnarability Scan') {
steps {
// echo 'todo'
sh 'trivy fs -f table -o trivy-usrs-fs-report.html . && cat trivy-usrs-fs-report.html'
}
}
stage('SonarQube Scan') {
steps {
withSonarQubeEnv('SonarQubeOC-DS') {
sh ''' $SCANNER_HOME/bin/sonar-scanner -Dsonar.projectName="url-shortener-redirection-service" -Dsonar.projectKey="url-shortener-redirection-service" \
-Dsonar.java.binaries=. '''
}
}
}
stage('Sonar Quality Gate') {
steps {
script {
waitForQualityGate abortPipeline: false, credentialsId: 'sonarqube-cred-d'
}
}
}
stage('Build') {
steps {
sh 'mvn package -DskipTests'
}
}
stage('Build & Push Multi-Arch Docker Image') {
steps {
script {
withDockerRegistry(credentialsId: 'dockerhub-cred-d') {
sh "docker buildx create --name mybuilder --use"
sh """docker buildx build \
--platform linux/amd64,linux/arm64 \
-t dipanshushukla/url-shortener-redirection-service:latest-dev \
--push ."""
}
}
}
}
stage('Trivy Docker Image Scan') {
steps {
sh 'trivy image -f table -o trivy-usrs-container-image-report.html dipanshushukla/url-shortener-redirection-service:latest-dev && cat trivy-usrs-container-image-report.html'
}
}
}
}