Commit 0695aaab authored by Henrik Skov Midtiby's avatar Henrik Skov Midtiby

Let the scheduled operations continue even if one of the tasks fails.

In that case emit an output message and continue.
parent 45845717
......@@ -64,7 +64,9 @@ class GitlabClassHelper:
if resp.ok:
print('Created project "%s" in "%s".' % (repo_name, group_name))
else:
raise requests.HTTPError('%s for url: %s' % (resp.json()['message'], url))
print('Failed to create project "%s" in "%s".' % (repo_name, group_name))
print(resp.json()['message'])
print(url)
def get_group_name(self, group_id: int) -> str:
"""
......@@ -117,7 +119,7 @@ class GitlabClassHelper:
if resp.ok:
print('Added userid "%d" to the project "%s".' % (user_id, repo_name))
else:
raise requests.HTTPError('%s for url: %s' % (resp.json()['message'], url))
print('User already exist - "%d" to the project "%s".' % (user_id, repo_name))
def push_git_repo_to_repositories(self, local_path: str, repositories: List[str], group_id: int = None):
"""
......@@ -153,14 +155,19 @@ class GitlabClassHelper:
Unprotect master branch
"""
use_group_id, _ = self.check_group_id(group_id)
for repo in repositories:
repo_id = self.get_repo_id(repo, use_group_id)
branch_url = self.path + '/projects/%d/protected_branches/master' % repo_id
branch_resp = requests.delete(branch_url, headers=self.headers)
if branch_resp.ok:
print('Unprotected master branch in project %s' % repo)
else:
raise requests.HTTPError('%s for url: %s' % (branch_resp.json()['message'], branch_url))
for repo in set(repositories):
print(repo)
try:
repo_id = self.get_repo_id(repo, use_group_id)
branch_url = self.path + '/projects/%d/protected_branches/master' % repo_id
branch_resp = requests.delete(branch_url, headers=self.headers)
if branch_resp.ok:
print('Unprotected master branch in project %s' % repo)
else:
raise requests.HTTPError('%s for url: %s' % (branch_resp.json()['message'], branch_url))
except Exception as e:
print("Something failed")
print(e)
def enter_class(self, group_name: str, id_of_parent_group: int) -> int:
"""
......
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