Skip to content
Snippets Groups Projects

Feat gl cicd var scripts

Merged Eesaan Atluri requested to merge atlurie/hpc-factory:feat-gl-cicd-var-scripts into main
1 file
+ 2
4
Compare changes
  • Side-by-side
  • Inline
@@ -18,7 +18,7 @@ def create_or_update_variable(project, var_dict):
key = var_dict.get("key")
scope = var_dict.get("environment_scope", "*")
p_variable = None
# Check if the variable exists in the project
# Fetch a variable with matching key and scope
try:
all_vars = project.variables.list(get_all=True)
for var in all_vars:
@@ -28,6 +28,7 @@ def create_or_update_variable(project, var_dict):
except gitlab.exceptions.GitlabGetError:
print("Variable not found")
exit(1)
# Check if the variable exists in the project
if p_variable:
if p_variable != var_dict:
# Check if the attributes are the same
@@ -35,7 +36,6 @@ def create_or_update_variable(project, var_dict):
if p_variable[k] != v:
# If not update the value in the project
print(f"Updating key {k} value")
# project.variables.update(k, {"value": v})
project.variables.update(
key,
{
@@ -60,7 +60,6 @@ def create_or_update_variable(project, var_dict):
def get_pipeline_vars_by_key(sched_pipeline, key_name):
p_vars = sched_pipeline.attributes["variables"]
# p_vars.sort(key=lambda x: x["key"])
for p_variable in p_vars:
if p_variable.get("key") == key_name:
return p_variable
@@ -124,7 +123,6 @@ def main():
# Load the CI vars file
var_list = load_file(args.var_file)
# var_list.sort(key=lambda x: x["key"])
# Create or update all variables
for var_dict in var_list:
Loading