-
Notifications
You must be signed in to change notification settings - Fork 13
/
.gitlab-ci.yml
203 lines (193 loc) · 6.65 KB
/
.gitlab-ci.yml
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# include:
# - project: enterprise-pipelines/gitlab-ci/includes
# file: SAST/sonarqube.yml
stages:
- build
- static-analysis
- deploy
default:
tags: [openshift]
.build-image:
interruptible: true
variables:
KUBERNETES_CPU_REQUEST: "500m"
KUBERNETES_CPU_LIMIT: "500m"
KUBERNETES_MEMORY_REQUEST: "768Mi"
KUBERNETES_MEMORY_LIMIT: "768Mi"
OCI_IMAGE_TAG: ${CI_COMMIT_SHORT_SHA}
image: registry.redhat.io/ubi8/buildah:latest
stage: build
script:
- buildah --storage-driver=${STORAGE_DRIVER:-vfs} bud ${BUILD_EXTRA_ARGS:-} --format=${IMAGE_FORMAT:-oci} --tls-verify=${TLS_VERIFY:-true} --no-cache -f ${CONTAINERFILE:-Dockerfile} -t ${OCI_IMAGE_NAME}:${OCI_IMAGE_TAG:-latest} ${BUILD_CONTEXT:-.}
- >
if [ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]; then
buildah --storage-driver=${STORAGE_DRIVER:-vfs} push --creds ${QUAY_CREDS_STAGE} ${PUSH_EXTRA_ARGS:-} --tls-verify=${TLS_VERIFY:-true} ${OCI_IMAGE_NAME}:${OCI_IMAGE_TAG:-latest} docker://${OCI_IMAGE_NAME}:${OCI_IMAGE_TAG:-latest}
else
echo "Skipping pushing image ${OCI_IMAGE_NAME}:${OCI_IMAGE_TAG:-latest}"
fi
rules:
# - if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
build:
image:
name: registry.access.redhat.com/ubi9@sha256:5ae30df1cf22d3f805b031eaf88218f6e084049cb30a8d22361f2a4f13eaa511
entrypoint: [""]
stage: build
cache:
key: maven
paths:
- .m2/repository
rules:
# - if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
variables:
KUBERNETES_CPU_REQUEST: "1500m"
KUBERNETES_CPU_LIMIT: "1500m"
KUBERNETES_MEMORY_REQUEST: "5Gi"
KUBERNETES_MEMORY_LIMIT: "5Gi"
MAVEN_OPTS: >-
-Dhttps.protocols=TLSv1.2
-Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository
-Dorg.slf4j.simpleLogger.showDateTime=true
-Djava.awt.headless=true
-XX:InitialRAMPercentage=50 -XX:MaxRAMPercentage=50 -XX:+ExitOnOutOfMemoryError -XshowSettings:vm
MAVEN_CLI_OPTS: >-
--batch-mode
--errors
--fail-at-end
--show-version
-DinstallAtEnd=true
-DdeployAtEnd=true
-Dsurefire.useFile=false
-Denforcer.skipRules=bannedRepositories
--no-transfer-progress
before_script:
- dnf -y --noplugins --setopt=install_weak_deps=0 --setopt=tsflags=nodocs upgrade
- dnf install -y --setopt=tsflags=nodocs unzip zip
- mkdir certs
- curl -L "https://${INTERNAL_CERTS_HOST}/certs/2022-IT-Root-CA.pem" -o certs/2022-IT-Root-CA.pem
- curl -L "https://${INTERNAL_CERTS_HOST}/certs/2015-IT-Root-CA.pem" -o certs/2015-IT-Root-CA.pem
- curl -s "https://get.sdkman.io" | bash
- echo "sdkman_auto_answer=true" > $HOME/.sdkman/etc/config
- source "$HOME/.sdkman/bin/sdkman-init.sh"
- sdk install java 17.0.12-tem
- keytool -import -trustcacerts -alias 2022-IT-Root-CA -file certs/2022-IT-Root-CA.pem -keystore "$HOME/.sdkman/candidates/java/17.0.12-tem/lib/security/cacerts" -noprompt -storepass changeit
- keytool -import -trustcacerts -alias 2015-IT-Root-CA -file certs/2015-IT-Root-CA.pem -keystore "$HOME/.sdkman/candidates/java/17.0.12-tem/lib/security/cacerts" -noprompt -storepass changeit
script:
- ./mvnw -s .ci/settings.xml verify ${MAVEN_CLI_OPTS} -DbuildNumber=${CI_COMMIT_SHORT_SHA} jacoco:report sonar:sonar -Dsonar.projectKey=SBOMer
artifacts:
when: always
reports:
junit:
- "**/target/surefire-reports/**/*.xml"
paths:
- service/target
- cli/target
- core/target
- e2e/target
- native/cli/runtime/target
- native/cli/deployment/target
build-ui:
image:
name: registry.access.redhat.com/ubi9/nodejs-20-minimal@sha256:a9701e3e63ab1e6bb8050eb31222696d70098ad54b0326d96449878b5319f1f6
entrypoint: [""]
stage: build
cache:
key: ui
paths:
- ui/node_modules
rules:
#- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
variables:
KUBERNETES_CPU_REQUEST: "1000m"
KUBERNETES_CPU_LIMIT: "1000m"
KUBERNETES_MEMORY_REQUEST: "2Gi"
KUBERNETES_MEMORY_LIMIT: "2Gi"
script:
- export REACT_APP_SBOMER_RELEASE=${CI_COMMIT_SHORT_SHA}
- export REACT_APP_SBOMER_BUILD_TIMESTAMP=$(date +%s)
- cd ui
- npm install
- npm run build
artifacts:
when: always
paths:
- ui/dist
build-image-service:
extends:
- .build-image
variables:
OCI_IMAGE_NAME: ${IMAGE_REGISTRY_STAGE}/sbomer-service
CONTAINERFILE: images/sbomer-service/Containerfile
before_script:
- mkdir certs
- curl -L "https://${INTERNAL_CERTS_HOST}/certs/2022-IT-Root-CA.pem" -o certs/2022-IT-Root-CA.pem
- curl -L "https://${INTERNAL_CERTS_HOST}/certs/2015-IT-Root-CA.pem" -o certs/2015-IT-Root-CA.pem
dependencies:
- build
needs:
- job: build
build-image-generator:
extends:
- .build-image
variables:
OCI_IMAGE_NAME: ${IMAGE_REGISTRY_STAGE}/sbomer-generator
CONTAINERFILE: images/sbomer-generator/Containerfile
before_script:
- mkdir certs
- curl -L "https://${INTERNAL_CERTS_HOST}/certs/2022-IT-Root-CA.pem" -o certs/2022-IT-Root-CA.pem
- curl -L "https://${INTERNAL_CERTS_HOST}/certs/2015-IT-Root-CA.pem" -o certs/2015-IT-Root-CA.pem
dependencies:
- build
needs:
- job: build
build-image-ui:
extends:
- .build-image
variables:
OCI_IMAGE_NAME: ${IMAGE_REGISTRY_STAGE}/sbomer-ui
CONTAINERFILE: images/sbomer-ui/Containerfile
dependencies:
- build-ui
needs:
- job: build-ui
pages:
image:
name: registry.access.redhat.com/ubi9@sha256:5ae30df1cf22d3f805b031eaf88218f6e084049cb30a8d22361f2a4f13eaa511
entrypoint: [""]
variables:
KUBERNETES_CPU_REQUEST: "100m"
KUBERNETES_CPU_LIMIT: "100m"
KUBERNETES_MEMORY_REQUEST: "256Mi"
KUBERNETES_MEMORY_LIMIT: "256Mi"
stage: build
script:
- dnf install -y --setopt=tsflags=nodocs make gcc-c++
- curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
- export NVM_DIR="$HOME/.nvm" && . "$NVM_DIR/nvm.sh" --no-use
- nvm install v18
- npm install --global yarn
- yarn install --frozen-lockfile --no-progress
- >
NODE_TLS_REJECT_UNAUTHORIZED=0
npx antora --fetch --to-dir public antora-playbook.yml
artifacts:
paths:
- public
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
deploy:
variables:
RELEASE_HASH: ${CI_COMMIT_SHORT_SHA}
stage: deploy
trigger:
project: appsvcs-platform/security/sbomer-helm
branch: main
strategy: depend
needs:
- job: build-image-generator
- job: build-image-service
- job: build-image-ui
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH