2021-09-27 22:37:18 +00:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
import time
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import gitlab
|
|
|
|
|
2021-10-05 15:20:32 +00:00
|
|
|
CERBERO_PROJECT = 'gstreamer/cerbero'
|
|
|
|
|
2021-09-27 22:37:18 +00:00
|
|
|
|
2021-10-05 00:24:58 +00:00
|
|
|
|
2021-09-27 22:37:18 +00:00
|
|
|
class Status:
|
|
|
|
FAILED = 'failed'
|
|
|
|
MANUAL = 'manual'
|
|
|
|
CANCELED = 'canceled'
|
|
|
|
SUCCESS = 'success'
|
|
|
|
SKIPPED = 'skipped'
|
|
|
|
CREATED = 'created'
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def is_finished(cls, state):
|
|
|
|
return state in [
|
|
|
|
cls.FAILED,
|
|
|
|
cls.MANUAL,
|
|
|
|
cls.CANCELED,
|
|
|
|
cls.SUCCESS,
|
|
|
|
cls.SKIPPED,
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
def fprint(msg):
|
|
|
|
print(msg, end="")
|
|
|
|
sys.stdout.flush()
|
|
|
|
|
2021-10-05 00:24:58 +00:00
|
|
|
|
2021-09-27 22:37:18 +00:00
|
|
|
if __name__ == "__main__":
|
2021-10-05 15:20:32 +00:00
|
|
|
server = os.environ['CI_SERVER_URL']
|
|
|
|
gl = gitlab.Gitlab(server,
|
2021-09-27 22:37:18 +00:00
|
|
|
private_token=os.environ.get('GITLAB_API_TOKEN'),
|
2021-10-05 15:20:32 +00:00
|
|
|
job_token=os.environ.get('CI_JOB_TOKEN'))
|
2021-09-27 22:37:18 +00:00
|
|
|
|
2021-10-05 15:20:32 +00:00
|
|
|
cerbero = gl.projects.get(CERBERO_PROJECT)
|
2021-09-27 22:37:18 +00:00
|
|
|
pipe = cerbero.trigger_pipeline(
|
|
|
|
token=os.environ['CI_JOB_TOKEN'],
|
2021-10-05 00:24:58 +00:00
|
|
|
ref=os.environ["GST_UPSTREAM_BRANCH"],
|
2021-09-27 22:37:18 +00:00
|
|
|
variables={
|
|
|
|
"CI_GSTREAMER_URL": os.environ["CI_PROJECT_URL"],
|
|
|
|
"CI_GSTREAMER_REF_NAME": os.environ["CI_COMMIT_REF_NAME"],
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
fprint(f'Cerbero pipeline running at {pipe.web_url} ')
|
|
|
|
while True:
|
|
|
|
time.sleep(15)
|
|
|
|
pipe.refresh()
|
|
|
|
if Status.is_finished(pipe.status):
|
|
|
|
fprint(f": {pipe.status}\n")
|
|
|
|
sys.exit(0 if pipe.status == Status.SUCCESS else 1)
|
|
|
|
else:
|
|
|
|
fprint(".")
|