-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
105 lines (104 loc) · 3.64 KB
/
Jenkinsfile
File metadata and controls
105 lines (104 loc) · 3.64 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
pipeline {
agent {
kubernetes {
yaml '''
apiVersion: v1
kind: Pod
metadata:
name: qlack-java
namespace: jenkins
spec:
tolerations:
- key: "jenkins"
operator: "Equal"
value: "agent"
effect: "NoSchedule"
nodeSelector:
jenkins-agent: "true"
priorityClassName: jenkins-low-priority
securityContext:
runAsUser: 0
runAsGroup: 0
fsGroup: 0
containers:
- name: qlack-java-builder
image: eddevopsd2/maven-java-npm-docker:mvn3.9.6-jdk21-node18-docker-npm8.0.0
volumeMounts:
- name: maven
mountPath: /root/.m2/
subPath: qlack-java
tty: true
securityContext:
privileged: true
runAsUser: 0
imagePullSecrets:
- name: regcred
volumes:
- name: maven
persistentVolumeClaim:
claimName: maven-nfs-pvc
'''
workspaceVolume persistentVolumeClaimWorkspaceVolume(claimName: 'workspace-nfs-pvc', readOnly: false)
}
}
options {
disableConcurrentBuilds()
buildDiscarder(logRotator(numToKeepStr: '10'))
}
stages {
stage('Build') {
steps {
container (name: 'qlack-java-builder'){
sh 'mvn clean install -Pfull-build'
}
}
}
stage('Sonar Analysis') {
steps {
container (name: 'qlack-java-builder'){
withSonarQubeEnv('sonar'){
sh 'mvn sonar:sonar -Dsonar.projectName=Qlack-Java -Dsonar.host.url=${SONAR_HOST_URL} -Dsonar.token=${SONAR_GLOBAL_KEY} -Dsonar.working.directory="/tmp"'
}
}
}
}
stage('Produce bom.xml'){
steps{
container (name: 'qlack-java-builder'){
sh 'mvn org.cyclonedx:cyclonedx-maven-plugin:makeAggregateBom'
}
}
}
stage('Dependency-Track Analysis'){
steps{
container (name: 'qlack-java-builder'){
sh '''
echo '{"project": "80c8d4aa-11fc-4841-af7e-bdd7b24f2d27", "bom": "'"$(cat target/bom.xml | base64 -w 0)"'"}' > payload.json
'''
sh '''
curl -X "PUT" ${DEPENDENCY_TRACK_URL} -H 'Content-Type: application/json' -H 'X-API-Key: '${DEPENDENCY_TRACK_API_KEY} -d @payload.json
'''
}
}
}
}
post {
changed {
emailext subject: '$DEFAULT_SUBJECT',
body: '$DEFAULT_CONTENT',
to: 'qlack@eurodyn.com'
script {
if (currentBuild.result == 'SUCCESS') {
emailext subject: '$DEFAULT_SUBJECT',
body: '$DEFAULT_CONTENT',
to: 'dd74bf6f.ed.eurodyn.com@emea.teams.ms'
}
if (currentBuild.result == 'FAILURE') {
emailext subject: '$DEFAULT_SUBJECT',
body: '$DEFAULT_CONTENT',
to: 'dd74bf6f.ed.eurodyn.com@emea.teams.ms'
}
}
}
}
}