-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
150 lines (148 loc) · 4.81 KB
/
Copy pathJenkinsfile
File metadata and controls
150 lines (148 loc) · 4.81 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
// SPDX-FileCopyrightText: (C) 2024 Intel Corporation
// SPDX-License-Identifier: LicenseRef-Intel
def getEnvFromBranch(branch) {
if (branch ==~ /main/) {
return 'virus'
}
else {
return 'virus'
// PR checks can be extended with checkmarx, bandit, snyk but source code has to available for them to pass. Protex should be kept only at branch level scanning.
}
}
pipeline {
agent {
docker {
label 'oie_spot_executor'
image 'amr-registry.caas.intel.com/one-intel-edge/rrp-devops/oie_ci_testing:latest'
alwaysPull true
args '--privileged -v /dev:/dev'
}
}
environment {
GIT_SHORT_URL=env.GIT_URL.split('/')[4].toString().replaceAll('.git','')
PROJECT_NAME = "${GIT_SHORT_URL}"
authorEmail = sh (script: 'git --no-pager show -s --format=\'%ae\'',returnStdout: true).trim()
SDLE_UPLOAD_PROJECT_ID = ' ' //add your SDL project
}
stages {
stage('Scan Sources'){
environment {
SCANNERS = getEnvFromBranch(env.BRANCH_NAME)
PROTEX_PROJECT_NAME = "${GIT_SHORT_URL}"
}
when {
anyOf {
branch 'main';
changeRequest();
}
}
steps {
rbheStaticCodeScan()
}
}
// This stage is required for service/agent repos only
// Please remove it for chart repos
stage('Version Check') {
steps {
echo "Check if its a valid code version"
sh '''
/opt/ci/version-check.sh
'''
}
}
stage('Build') {
steps {
echo "Hi, I'm a pipeline, doing build step"
echo "For time-being skipped, make build stage due to- Host OS image download failed"
echo "The ISO download and mounting are now working (you can see the successful mount with read-only warning, which is normal for ISOs). However, the build is still failing during the Starting Installation phase"
}
}
stage('License Check') {
steps {
sh '''
echo "License checking the code"
make license
'''
}
}
stage('Lint') {
steps {
echo "Hi, I'm a pipeline, doing lint step"
sh '''
make lint
'''
}
}
stage('Test') {
when {
changeRequest()
}
steps {
echo "Hi, I'm a pipeline, doing test step"
}
post {
success {
coverageReport('cobertura-coverage.xml')
}
}
}
// This stage is required for service/agent repos only
// Please remove it for chart repos
stage('Version Tag') {
when {
anyOf { branch 'main'; branch 'feature*'; branch 'release*' }
}
steps {
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'sys_oie_devops_github_api',usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']])
{
netrcPatch()
echo "Generate tag if SemVer"
sh '''
# Tag the version
/opt/ci/version-tag.sh
'''
}
}
}
stage('Version dev') {
when {
anyOf { branch 'main'; branch 'iaas-*-*'; branch 'release-*'; }
}
steps {
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'sys_oie_devops_github_api',usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']])
{
versionDev()
}
}
}
stage('Auto approve') {
when {
changeRequest()
}
steps {
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'sys_devops_approve_github_api', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
script {
autoApproveAndMergePR()
}
}
}
}
stage('Artifact') {
steps {
artifactUpload()
}
}
}
post {
always {
jcpSummaryReport()
intelLogstashSend failBuild: false, verbose: true
cleanWs()
}
failure {
script {
emailFailure()
}
}
}
}