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
13
Compare changes
  • Side-by-side
  • Inline
@@ -28,25 +28,14 @@ def create_or_update_variable(project, var_dict):
@@ -28,25 +28,14 @@ def create_or_update_variable(project, var_dict):
except gitlab.exceptions.GitlabGetError:
except gitlab.exceptions.GitlabGetError:
print("Variable not found")
print("Variable not found")
exit(1)
exit(1)
project.variables.update(
key,
{
"value": var_dict["value"],
"environment_scope": scope,
"variable_type": var_dict.get("variable_type", "env_var"),
"masked": var_dict.get("masked", False),
"protected": var_dict.get("protected", False),
"raw": var_dict.get("raw", False),
"description": var_dict.get("description", None),
},
)
break
# Check if the variable exists and same as input
# Check if the variable exists and same as input
if p_variable is not None:
if p_variable is not None:
if p_variable.asdict() != var_dict:
if p_variable.asdict() != var_dict:
# if not same update the project variable
# if not same update the project variable
print(f"Updating {p_variable.attributes['key']}")
print(f"Updating {p_variable.attributes['key']}")
 
p_variable.delete()
 
return project.variables.create(var_dict)
else:
else:
print(f"variable {var_dict["key"]} already exists")
print(f"variable {var_dict["key"]} already exists")
# Create variable if it doesn't exist in the project
# Create variable if it doesn't exist in the project
Loading