Hello
I’ve made a function that import a project in a group from a template, but I can’t figure out how I can specify the path when I import. I try many parameters namespace,namespace_id, full_path,parent_id etc… but it imports the project always in my home. Maybe you can help me ? thanks
def create_project(app_group_id, subname, appname):
app_group=gitl.groups.get(app_group_id)
spoke_id = get_subgroup_id(app_group_id,"Spoke")
fullpath="iac/azure/subscriptions/" + subname + "/applications/" + appname + "/"
if spoke_id != "NOK":
print("Project Spoke already exists in application group", app_group[-1].name , " , nothing done")
return(False)
else:
p = gitl.projects.get(project_model_id)
export = p.exports.create()
# Wait for the 'finished' status
export.refresh()
while export.export_status != 'finished':
time.sleep(1)
export.refresh()
# Download the result
with open('./export.tgz', 'wb') as f:
export.download(streamed=True, action=f.write)
print("app_group_id = ", app_group_id)
output = gitl.projects.import_project(open('./export.tgz', 'rb'),name_with_namespace=fullpath, parent_id=app_group_id, path='Spoke')
# Get a ProjectImport object to track the import status
project_import = gitl.projects.get(output['id'], lazy=True).imports.get()
print("project_import : ", project_import)
while project_import.import_status != 'finished':
time.sleep(1)
project_import.refresh()
spoke_id = get_subgroup_id(app_group_id,"Spoke")
return spoke_id
return(False)
def main():
for subgr in csv_f.iterrows():
sub = subgr[1][3]
appname = subgr[1][2]
print("Start creation of ", appname )
app_id=create_app_folders(subgr)
spoke_id=create_project(app_id,sub,appname)