]> Git Repo - qemu.git/commitdiff
scripts/ci/gitlab-pipeline-status: wait for pipeline creation
authorCleber Rosa <[email protected]>
Fri, 4 Sep 2020 16:42:58 +0000 (12:42 -0400)
committerThomas Huth <[email protected]>
Tue, 13 Oct 2020 10:48:17 +0000 (12:48 +0200)
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 <[email protected]>
Message-Id: <20200904164258[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
scripts/ci/gitlab-pipeline-status

index 628150ce0bab2c125e8f56f15a9b076a98bfcce7..bac8233079bb60d57074314be7af8b234e3ac90e 100755 (executable)
@@ -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']
This page took 0.02494 seconds and 4 git commands to generate.