forked from RedHatInsights/vulnerability-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
142 lines (127 loc) · 5.09 KB
/
Jenkinsfile
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
def secrets = [
[path: params.VAULT_PATH_SVC_ACCOUNT_EPHEMERAL, engineVersion: 1, secretValues: [
[envVar: 'OC_LOGIN_TOKEN_DEV', vaultKey: 'oc-login-token-dev'],
[envVar: 'OC_LOGIN_SERVER_DEV', vaultKey: 'oc-login-server-dev']]],
[path: params.VAULT_PATH_QUAY_PUSH, engineVersion: 1, secretValues: [
[envVar: 'QUAY_USER', vaultKey: 'user'],
[envVar: 'QUAY_TOKEN', vaultKey: 'token']]],
[path: params.VAULT_PATH_RHR_PULL, engineVersion: 1, secretValues: [
[envVar: 'RH_REGISTRY_USER', vaultKey: 'user'],
[envVar: 'RH_REGISTRY_TOKEN', vaultKey: 'token']]],
[path: params.VAULT_PATH_QUAY_TOKEN, engineVersion: 1, secretValues: [
[envVar: 'QUAY_API_TOKEN', vaultKey: 'api-token']]]
]
def configuration = [vaultUrl: params.VAULT_ADDRESS, vaultCredentialId: params.VAULT_CREDS_ID, engineVersion: 1]
pipeline {
agent { label 'insights' }
options {
timestamps()
}
environment {
APP_NAME="vulnerability" // name of app-sre "application" folder this component lives in
COMPONENT_NAME="vulnerability-engine" // name of app-sre "resourceTemplate" in deploy.yaml for this component
IMAGE="quay.io/cloudservices/vulnerability-engine-app"
COMPONENTS_W_RESOURCES="vmaas rbac"
CACHE_FROM_LATEST_IMAGE="true"
IQE_PLUGINS="vulnerability"
IQE_MARKER_EXPRESSION="smoke and api"
IQE_FILTER_EXPRESSION="not (advisories or patch or remediation_manual or test_dash or test_edge_leak or test_executive_report)"
IQE_REQUIREMENTS_PRIORITY=""
IQE_TEST_IMPORTANCE=""
IQE_CJI_TIMEOUT="60m"
DEPLOY_TIMEOUT=900
// Heavily inspired by project-koku pr_check
// https://github.com/project-koku/koku/blob/main/pr_check.sh
LABELS_DIR="$WORKSPACE/github_labels"
ARTIFACTS_DIR="$WORKSPACE/artifacts"
}
stages {
stage('Initial setup') {
steps {
sh '''
source ./ci/functions.sh
set_label_flags
> stage_flags
echo "RELEASE_NAMESPACE:$RELEASE_NAMESPACE" >> stage_flags
echo "SKIP_DEPLOY_EPHEMERAL:$SKIP_DEPLOY_EPHEMERAL" >> stage_flags
echo "SKIP_IMAGE_BUILD:$SKIP_IMAGE_BUILD" >> stage_flags
echo "SKIP_SMOKE_TEST:$SKIP_SMOKE_TEST" >> stage_flags
'''
script {
FILE_CONTENTS = readFile('stage_flags')
my_var_map = [:]
my_vars = FILE_CONTENTS.split()
for (i in my_vars) {
s=i.split(':')
if (s.length == 2) {
my_var_map[s[0]] = s[1]
} else {
my_var_map[s[0]] = ""
}
}
env.RELEASE_NAMESPACE = my_var_map['RELEASE_NAMESPACE']
env.SKIP_BUILD = my_var_map['SKIP_BUILD']
env.SKIP_DEPLOY_EPHEMERAL = my_var_map['SKIP_DEPLOY_EPHEMERAL']
env.SKIP_IMAGE_BUILD = my_var_map['SKIP_IMAGE_BUILD']
env.SKIP_SMOKE_TEST = my_var_map['SKIP_SMOKE_TEST']
}
}
}
stage('Build test image') {
when {
expression {
return (! env.SKIP_IMAGE_BUILD)
}
}
steps {
script {
withVault([configuration: configuration, vaultSecrets: secrets]) {
sh '''
source ./ci/functions.sh
echo "Install bonfire repo/initialize, creating PR image"
run_build_image_stage
'''
}
}
}
}
stage('Deploy Ephemeral Environment') {
when {
expression {
return (! env.SKIP_DEPLOY_EPHEMERAL)
}
}
steps {
script {
withVault([configuration: configuration, vaultSecrets: secrets]) {
sh '''
source ./ci/functions.sh
deploy_ephemeral_stage
'''
}
}
}
}
stage('Run Smoke Tests') {
when {
expression {
return (! env.SKIP_SMOKE_TEST)
}
}
steps {
script {
withVault([configuration: configuration, vaultSecrets: secrets]) {
sh '''
source ./ci/functions.sh
echo "running PR smoke tests"
set +e
process_requirements_labels
set -e
run_smoke_tests_stage
'''
}
}
}
}
}
}