Commit f0be8d78 authored by Faizan Azim's avatar Faizan Azim 🤓

added merge request logic.

parent eb6d7d8d
......@@ -205,7 +205,7 @@ if __name__ == '__main__':
module_name=_file.split(".yml")[0])
push_helm_deployments(helm_repo, git_access_token, _client_name, final_helm_path=OUTPUT_PATH,
base_path=helm_path)
git_handler_obj.create_merge_request(repo_link=helm_repo, source_branch=_branch, destination_branch=_client_name)
except Exception as e:
logging.exception(f"Exception Occurred while processing the Helm-Script Preparation {e.args}")
finally:
......
......@@ -89,3 +89,20 @@ class GitHandler:
return False
items = pl.repository_tree(path=HELM_PATH, ref=branch)
print(items)
def create_merge_request(self, repo_link: str, source_branch: str, destination_branch: str):
base_url = os.environ.get("GIT_BASE_URL", default=default_link)
repo_link_split = repo_link.split(base_url)
if not repo_link_split:
return False
gl = gitlab.Gitlab(url=base_url, private_token=self.access_token)
search_str = repo_link_split[-1].replace(".git", "")
if pl := gl.projects.list(search=search_str):
pl = pl[0]
else:
return False
pl.mergerequests.create({
'source_branch': source_branch,
'target_branch': destination_branch,
'title': f'{source_branch} merge'
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment