Skip to content

Commit 88ebecf

Browse files
committed
Inject additional repositories for server and proxy
1 parent dc5ff67 commit 88ebecf

File tree

5 files changed

+36
-1
lines changed

5 files changed

+36
-1
lines changed

jenkins_pipelines/environments/common/pipeline-build-validation.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ def run(params) {
104104
commonArgs += " --inject CUCUMBER_BRANCH=${params.cucumber_ref}"
105105
if (product_version) { commonArgs += " --inject PRODUCT_VERSION=${product_version}" }
106106
if (base_os) { commonArgs += " --inject BASE_OS=${base_os}" }
107+
if ( fileExists('custom_repositories.json')) {
108+
commonArgs += " --custom-repositories-json ${WORKSPACE}/custom_repositories.json"
109+
}
107110

108111
// Personal scenario specific arguments
109112
def scenarioArgs = ""

jenkins_pipelines/scripts/tf_vars_generator/prepare_tfvars.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import argparse
2+
import json
23
import logging
34
import sys
45
import re
@@ -194,6 +195,7 @@ def save(self, output_path):
194195
parser.add_argument("--string-registry", default="false")
195196
parser.add_argument("--merge-files", nargs='*', default=[], help="Files to merge (Scenario Classic BV)")
196197
parser.add_argument("--inject", action='append', help="KEY=VALUE")
198+
parser.add_argument("--custom-repositories-json", default="", help="JSON file defining additional repositories")
197199

198200
# Cleaning Args
199201
parser.add_argument("--clean", action='store_true', help="Enable resource cleaning")
@@ -236,8 +238,22 @@ def save(self, output_path):
236238
if args.inject:
237239
for item in args.inject:
238240
if '=' in item:
239-
k, v = item.split('=', 1)
241+
k, v = item.split('=', 1)
240242
vars_to_inject[k] = v
243+
244+
# INJECT CUSTOM REPOSITORIES FOR SERVER AND PROXY
245+
if args.custom_repositories_json:
246+
try:
247+
with open(args.custom_repositories_json, 'r') as f:
248+
repos: dict = json.load(f)
249+
except Exception as e:
250+
print(f"\n[ERROR]: Failed to parse custom repositorie JSON file at {args.custom_repositories_json}. Error: {e}")
251+
sys.exit(1)
252+
253+
for k in ["server", "proxy"]:
254+
if k in repos:
255+
vars_to_inject[f"{k.upper()}_ADDITIONAL_REPOS"] = repos[k]
256+
241257
gen.inject_variables(vars_to_inject)
242258

243259
# CLEANING

terracumber_config/tf_files/templates/build-validation-multi-providers.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ module "build_validation_module" {
224224

225225
server_container_repository = var.SERVER_CONTAINER_REPOSITORY
226226
server_container_image = var.SERVER_CONTAINER_IMAGE
227+
server_additional_repos = var.SERVER_ADDITIONAL_REPOS
227228
proxy_container_repository = var.PROXY_CONTAINER_REPOSITORY
229+
proxy_additional_repos = var.PROXY_ADDITIONAL_REPOS
228230
base_os = var.BASE_OS
229231
}
230232

terracumber_config/tf_files/templates/build-validation-single-provider.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ module "build_validation_module" {
8484

8585
server_container_repository = var.SERVER_CONTAINER_REPOSITORY
8686
server_container_image = var.SERVER_CONTAINER_IMAGE
87+
server_additional_repos = var.SERVER_ADDITIONAL_REPOS
8788
proxy_container_repository = var.PROXY_CONTAINER_REPOSITORY
89+
proxy_additional_repos = var.PROXY_ADDITIONAL_REPOS
8890
base_os = var.BASE_OS
8991
}
9092

terracumber_config/tf_files/variables/build-validation-variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,24 @@ variable "SERVER_CONTAINER_REPOSITORY" {
114114
default = ""
115115
}
116116

117+
variable "SERVER_ADDITIONAL_REPOS" {
118+
type = map(string)
119+
description = "extra server repositories in the form {label = url}"
120+
default = {}
121+
}
122+
117123
variable "PROXY_CONTAINER_REPOSITORY" {
118124
type = string
119125
description = "Proxy container registry path, not needed for 4.3"
120126
default = ""
121127
}
122128

129+
variable "PROXY_ADDITIONAL_REPOS" {
130+
type = map(string)
131+
description = "extra proxy repositories in the form {label = url}"
132+
default = {}
133+
}
134+
123135
variable "SERVER_CONTAINER_IMAGE" {
124136
type = string
125137
description = "Server container image, not needed for 4.3"

0 commit comments

Comments
 (0)