Repository navigation
Expand file tree
/
Copy pathJenkinsfile_ci
More file actions
158 lines (150 loc) · 5.89 KB
/
Copy pathJenkinsfile_ci
File metadata and controls
158 lines (150 loc) · 5.89 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
pipeline {
agent {
kubernetes {
inheritFrom 'cicd-agent'
yaml '''
apiVersion: v1
kind: Pod
metadata:
name: qlack-typescript-ci
namespace: jenkins
spec:
priorityClassName: jenkins-low-priority
securityContext:
runAsUser: 0
runAsGroup: 0
fsGroup: 0
containers:
- name: qlack-typescript-builder
image: eddevopsd2/ubuntu-dind:dind-mvn3.8.5-jdk17-node18.16-go1.20-buildx-helm-pip
volumeMounts:
- name: sonar-scanner
mountPath: /root/sonar-scanner
tty: true
securityContext:
privileged: true
runAsUser: 0
resources:
requests:
cpu: "1"
memory: "1Gi"
limits:
cpu: "2"
memory: "2Gi"
- name: node20
image: eddevopsd2/npm-docker:node20-npm-10-docker
tty: true
resources:
requests:
cpu: "250m"
memory: "256Mi"
limits:
cpu: "1"
memory: "1Gi"
imagePullSecrets:
- name: regcred
volumes:
- name: sonar-scanner
persistentVolumeClaim:
claimName: sonar-scanner-nfs-pvc
'''
workspaceVolume dynamicPVC(accessModes: 'ReadWriteOnce', requestsSize: '10Gi', storageClassName: 'vsphere-csi-sc')
}
}
options {
disableConcurrentBuilds()
buildDiscarder(logRotator(numToKeepStr: '10'))
timeout(time: 3, unit: 'HOURS')
}
stages {
stage ('Install-Qlack-Dependencies') {
steps {
container (name: 'qlack-typescript-builder') {
script {
sh 'npm install'
if(env.publishFormValidation == 'true'){
dir('projects/qlack/form-validation') {
sh 'echo "install dependencies for qlack form-validation"'
sh 'npm install'
}
}
if(env.publishForms == 'true'){
dir('projects/qlack/forms') {
sh 'echo "install dependencies for qlack forms"'
sh 'npm install'
}
}
if(env.publishQngPubsub == 'true'){
dir('projects/qlack/qng-pubsub') {
sh 'echo "install dependencies for qlack qng-pubsub"'
sh 'npm install'
}
}
}
}
}
}
stage ('Build-Qlack') {
steps {
container (name: 'qlack-typescript-builder') {
script {
// install angular cli
sh 'npm install -g @angular/cli'
if(env.publishFormValidation == 'true'){
dir('projects/qlack/form-validation') {
sh 'echo "build qlack form-validation"'
sh 'npx ng build --project @qlack/form-validation'
}
}
if(env.publishForms == 'true'){
dir('projects/qlack/forms') {
sh 'echo "build qlack forms"'
sh 'npx ng build --project @qlack/forms'
}
}
if(env.publishQngPubsub == 'true'){
dir('projects/qlack/qng-pubsub') {
sh 'echo "build qlack qng-pubsub"'
sh 'npx ng build --project @qlack/qng-pubsub'
}
}
}
}
}
}
stage('Produce bom.xml') {
steps{
container (name: 'node20') {
sh '''
npm install --global @cyclonedx/cyclonedx-npm xmlbuilder2
cyclonedx-npm --ignore-npm-errors --output-format xml --output-file bom.xml
'''
}
}
}
stage('Dependency-Track Analysis') {
steps{
container (name: 'qlack-typescript-builder') {
sh '''
DT_BRANCH=$(echo "${BRANCH_NAME:-unknown}" | tr "/ " "__")
curl -sS -X POST "${DEPENDENCY_TRACK_URL}" \
-H "X-Api-Key: ${DEPENDENCY_TRACK_API_KEY}" \
-F "autoCreate=true" \
-F "parentName=QLACK-Typescript" \
-F "parentVersion=parent" \
-F "projectName=QLACK-Typescript" \
-F "projectVersion=${DT_BRANCH}" \
-F "bom=@bom.xml"
'''
}
}
}
stage('Sonar Analysis') {
steps {
container (name: 'qlack-typescript-builder') {
sh '/root/sonar-scanner/sonar-scanner/bin/sonar-scanner -Dsonar.projectName=Qlack-Typescript -Dsonar.host.url=${SONAR_HOST_URL} -Dsonar.token=${SONAR_GLOBAL_KEY} -Dsonar.working.directory="/tmp"'
}
}
}
}
}