[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 7/7] scripts/ci/gitlab-pipeline-status: wait for pipeline creatio
From: |
Cleber Rosa |
Subject: |
[PATCH 7/7] scripts/ci/gitlab-pipeline-status: wait for pipeline creation |
Date: |
Fri, 4 Sep 2020 12:42:58 -0400 |
When called in wait mode, this script will also wait for the pipeline
to be get to a "running" state. Because many more status may be seen
until a pipeline gets to "running", and those need to be handle too.
Reference: https://docs.gitlab.com/ee/api/pipelines.html#list-project-pipelines
Signed-off-by: Cleber Rosa <crosa@redhat.com>
---
scripts/ci/gitlab-pipeline-status | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/scripts/ci/gitlab-pipeline-status
b/scripts/ci/gitlab-pipeline-status
index 628150ce0b..bac8233079 100755
--- a/scripts/ci/gitlab-pipeline-status
+++ b/scripts/ci/gitlab-pipeline-status
@@ -83,13 +83,22 @@ def wait_on_pipeline_success(timeout, interval,
print(msg)
return False
- status = get_pipeline_status(project_id, commit_sha)
- if status['status'] == 'running':
- print('running...')
+ try:
+ status = get_pipeline_status(project_id, commit_sha)
+ except NoPipelineFound:
+ print('Pipeline has not been found, it may not have been created
yet.')
+ time.sleep(1)
+ continue
+
+ pipeline_status = status['status']
+ status_to_wait = ('created', 'waiting_for_resource', 'preparing',
+ 'pending', 'running')
+ if pipeline_status in status_to_wait:
+ print('%s...' % pipeline_status)
time.sleep(interval)
continue
- if status['status'] == 'success':
+ if pipeline_status == 'success':
return True
msg = "Pipeline failed, check: %s" % status['web_url']
--
2.25.4
- [PATCH 0/7] gitlab pipeline check/watch script improvements, Cleber Rosa, 2020/09/04
- [PATCH 2/7] scripts/ci/gitlab-pipeline-status: improve message regarding timeout, Cleber Rosa, 2020/09/04
- [PATCH 3/7] scripts/ci/gitlab-pipeline-status: give early feedback on running pipelines, Cleber Rosa, 2020/09/04
- [PATCH 6/7] scripts/ci/gitlab-pipeline-status: use more descriptive exceptions, Cleber Rosa, 2020/09/04
- [PATCH 7/7] scripts/ci/gitlab-pipeline-status: wait for pipeline creation,
Cleber Rosa <=
- [PATCH 4/7] scripts/ci/gitlab-pipeline-status: refactor parser creation, Cleber Rosa, 2020/09/04
- [PATCH 1/7] scripts/ci/gitlab-pipeline-status: make branch name configurable, Cleber Rosa, 2020/09/04
- [PATCH 5/7] scripts/ci/gitlab-pipeline-status: handle keyboard interrupts, Cleber Rosa, 2020/09/04