mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-22 08:17:01 +00:00
d4296b7d3d
When GStreamer is forked into a private GitLab instance we should trigger cerbero into that private instance too. Otherwise the token won't be accepted. Also do not hardcode the cerbero project ID because it is instance specific. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1056>
60 lines
1.4 KiB
Python
Executable file
60 lines
1.4 KiB
Python
Executable file
#!/usr/bin/python3
|
|
|
|
import time
|
|
import os
|
|
import sys
|
|
import gitlab
|
|
|
|
CERBERO_PROJECT = 'gstreamer/cerbero'
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
server = os.environ['CI_SERVER_URL']
|
|
gl = gitlab.Gitlab(server,
|
|
private_token=os.environ.get('GITLAB_API_TOKEN'),
|
|
job_token=os.environ.get('CI_JOB_TOKEN'))
|
|
|
|
cerbero = gl.projects.get(CERBERO_PROJECT)
|
|
pipe = cerbero.trigger_pipeline(
|
|
token=os.environ['CI_JOB_TOKEN'],
|
|
ref=os.environ["GST_UPSTREAM_BRANCH"],
|
|
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(".")
|