Skip to content
Snippets Groups Projects
Commit 17fc8af1 authored by jurgenhaas's avatar jurgenhaas
Browse files

ansible-playbooks/general#66 Back to parallel sanity execution and temporarily...

ansible-playbooks/general#66 Back to parallel sanity execution and temporarily retry issue creation if required
parent a215510b
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@
RETURN = '''# '''
import datetime
import random
try:
import gitlab
HAS_GITLAB_PACKAGE = True
......@@ -177,9 +178,9 @@ def main():
# or with login_token
try:
if use_credentials:
git = gitlab.Gitlab(server_url, email=login_user, password=login_password, ssl_verify=verify_ssl)
git = gitlab.Gitlab(server_url, email=login_user, password=login_password, ssl_verify=verify_ssl) # type: gitlab
else:
git = gitlab.Gitlab(server_url, login_token, ssl_verify=verify_ssl)
git = gitlab.Gitlab(server_url, login_token, ssl_verify=verify_ssl) # type: gitlab
git.auth()
except Exception, e:
module.fail_json(msg="Failed to connect to Gitlab server: %s " % e)
......@@ -245,7 +246,17 @@ def main():
"labels": ','.join(labels)
}
issue = git.project_issues.create(arguments, project_id=project.pid)
# Create issue and retry up to 3 times if that fails
issue = False
delay = random.randint(0, 200) / 100
retries = 3
while retries > 0:
retries -= 1
time.sleep(delay)
issue = git.project_issues.create(arguments, project_id=project.pid)
if issue:
retries = 0
if issue:
if close:
issue.state_event = 'close'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment