Skip to content

Commit fd56a74

Browse files
authored
Merge pull request #1406 from NVIDIA/update-release-ci-on-release-0.17
[no-relnote] update ngc publishing logic for release pipelines
2 parents 5665394 + 6c87d83 commit fd56a74

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed

.common-ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ stages:
2828
- test
2929
- scan
3030
- release
31+
- ngc-publish
3132

3233
.pipeline-trigger-rules:
3334
rules:

.nvidia-ci.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,110 @@ image-ubi9:
101101
- vulns.json
102102
- policy_evaluation.json
103103

104+
.ngc-publish-variables:
105+
variables:
106+
PROJECT_NAME: "k8s-device-plugin"
107+
VERSIONS_FILE: "build-info-${CI_PIPELINE_ID}.txt"
108+
before_script:
109+
- |
110+
if [ -n "${CI_COMMIT_TAG}" ]; then
111+
echo "${CI_COMMIT_SHORT_SHA} ${CI_COMMIT_TAG}" > "${VERSIONS_FILE}"
112+
else
113+
echo "${CI_COMMIT_SHORT_SHA} publish-${CI_COMMIT_SHORT_SHA}" > "${VERSIONS_FILE}"
114+
fi
115+
116+
.update-nspect:
117+
stage: ngc-publish
118+
needs:
119+
- job: release:staging-ubi9
120+
extends:
121+
- .ngc-publish-variables
122+
image:
123+
name: "${CNT_NGC_PUBLISH_IMAGE}"
124+
pull_policy: always
125+
variables:
126+
REPO_URL: "https://github.com/NVIDIA/${PROJECT_NAME}.git"
127+
script:
128+
- |
129+
cnt-ngc-publish nspect --versions-file "${VERSIONS_FILE}"
130+
131+
# Update the nspect staging environment to test the nspect publishing logic
132+
update-nspect-staging:
133+
extends:
134+
- .update-nspect
135+
rules:
136+
- if: $CI_COMMIT_TAG == null || $CI_COMMIT_TAG == ""
137+
variables:
138+
ENV: "stage"
139+
RELEASE_VERSION: "test"
140+
NSPECT_CLIENT_ID: "${NSPECT_STAGING_CLIENT_ID}"
141+
NSPECT_CLIENT_SECRET: "${NSPECT_STAGING_CLIENT_SECRET}"
142+
143+
# Update the nspect production environment with the new release
144+
update-nspect:
145+
extends:
146+
- .update-nspect
147+
rules:
148+
- if: $CI_COMMIT_TAG
149+
variables:
150+
OSRB_BUG_ID: "${OSRB_BUG_ID}"
151+
ENV: "prod"
152+
RELEASE_VERSION: "${CI_COMMIT_TAG}"
153+
NSPECT_CLIENT_ID: "${NSPECT_PROD_CLIENT_ID}"
154+
NSPECT_CLIENT_SECRET: "${NSPECT_PROD_CLIENT_SECRET}"
155+
156+
.publish-images:
157+
stage: ngc-publish
158+
extends:
159+
- .ngc-publish-variables
160+
image:
161+
name: "${CNT_NGC_PUBLISH_IMAGE}"
162+
pull_policy: always
163+
variables:
164+
GITLAB_ACCESS_TOKEN: "${CNT_GITLAB_TOKEN}"
165+
# Allow for setting nspect program version manually.
166+
# The default empty string value results in the key
167+
# being omitted from the publishing doc (which is
168+
# valid).
169+
NSPECT_PROGRAM_VERSION: ""
170+
script:
171+
- |
172+
if [ -z "${NGC_PUBLISHING_PROJECT_PATH}" ]; then
173+
echo "NGC_PUBLISHING_PROJECT_PATH not set"
174+
exit 1
175+
fi
176+
177+
echo "publishing to ${NGC_PUBLISHING_PROJECT_PATH}"
178+
179+
cnt-ngc-publish render \
180+
--project-name "${PROJECT_NAME}" \
181+
--versions-file "${VERSIONS_FILE}" \
182+
--output "${PROJECT_NAME}.yaml" \
183+
--nspect-program-version "${NSPECT_PROGRAM_VERSION}"
184+
- cnt-ngc-publish merge-request --files "${PROJECT_NAME}.yaml"
185+
artifacts:
186+
paths:
187+
- "${VERSION_FILE}"
188+
- "${PROJECT_NAME}.yaml"
189+
190+
# Raise an MR to publish the image to NGC
191+
ngc-image-publish:
192+
extends:
193+
- .publish-images
194+
rules:
195+
- if: $CI_COMMIT_TAG
196+
needs:
197+
- job: update-nspect
198+
variables:
199+
NGC_PUBLISHING_PROJECT_PATH: "${NGC_PUBLISHING_PROD_PROJECT_PATH}"
200+
201+
# Create a dummy MR that exercises the publishing logic
202+
mock-image-publish:
203+
extends:
204+
- .publish-images
205+
rules:
206+
- if: $CI_COMMIT_TAG == null || $CI_COMMIT_TAG == ""
207+
needs:
208+
- job: update-nspect-staging
209+
variables:
210+
NGC_PUBLISHING_PROJECT_PATH: "${NGC_PUBLISHING_TEST_PROJECT_PATH}"

0 commit comments

Comments
 (0)