-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJenkinsfile
More file actions
100 lines (99 loc) · 3.38 KB
/
Copy pathJenkinsfile
File metadata and controls
100 lines (99 loc) · 3.38 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
pipeline {
agent {
kubernetes {
inheritFrom 'cicd-agent'
yaml '''
apiVersion: v1
kind: Pod
metadata:
name: qlack-webdesktop
namespace: jenkins
spec:
priorityClassName: jenkins-low-priority
securityContext:
runAsUser: 0
runAsGroup: 0
containers:
- name: qlack-webdesktop-builder
image: eddevopsd2/maven-java-npm-docker:mvn3.6.3-jdk8-npm6.14.4-docker
volumeMounts:
- name: maven
mountPath: /root/.m2/
subPath: qlack-webdesktop
tty: true
securityContext:
privileged: true
runAsUser: 0
fsGroup: 0
resources:
requests:
cpu: "1"
memory: "1Gi"
limits:
cpu: "2"
memory: "2Gi"
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-webdesktop-builder'){
sh 'mvn clean install'
}
}
}
stage('Sonar Analysis') {
steps {
container (name: 'qlack-webdesktop-builder'){
withSonarQubeEnv('sonar'){
sh 'update-alternatives --set java /usr/lib/jvm/java-11-openjdk-amd64/bin/java'
sh 'mvn sonar:sonar -Dsonar.projectName=Qlack-WebDesktop -Dsonar.host.url=${SONAR_HOST_URL} -Dsonar.token=${SONAR_GLOBAL_KEY} -Dsonar.working.directory="/tmp"'
}
}
}
}
stage('Produce bom.xml'){
steps{
container (name: 'qlack-webdesktop-builder'){
sh 'mvn org.cyclonedx:cyclonedx-maven-plugin:makeAggregateBom'
}
}
}
stage('Dependency-Track Analysis'){
steps{
container (name: 'qlack-webdesktop-builder'){
sh '''
cat > payload.json <<__HERE__
{
"project": "f45fcd24-c172-4e15-9c3c-749e651d1385",
"bom": "$(cat target/bom.xml |base64 -w 0 -)"
}
__HERE__
'''
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'
}
}
}