-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard_url.py
More file actions
39 lines (31 loc) · 1.04 KB
/
dashboard_url.py
File metadata and controls
39 lines (31 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""Helper script to generate and print a fake dashboard URL.
The script constructs a dashboard URL for the current environment using predefined CI
variables: https://docs.gitlab.com/ci/variables/predefined_variables/
The URL points to the GitLab pages of this repository which hosts the static pages for
the test app that can be found in the ``public`` directory.
"""
import os
import sys
pages_url = os.environ.get("CI_PAGES_URL")
if pages_url is None:
print("CI_PAGES_URL ?", file=sys.stderr)
sys.exit(1)
project_id = os.environ.get("CI_PROJECT_ID")
if project_id is None:
print("CI_PROJECT_ID ?", file=sys.stderr)
sys.exit(1)
pipeline_id = os.environ.get("CI_PIPELINE_ID")
if pipeline_id is None:
print("CI_PIPELINE_ID ?", file=sys.stderr)
sys.exit(1)
job_id = os.environ.get("CI_JOB_ID")
if job_id is None:
print("CI_JOB_ID ?", file=sys.stderr)
sys.exit(1)
# good enough ;-)
print(
f"{pages_url}/callback"
f"?gitlab_project_id={project_id}"
f"&gitlab_pipeline_id={pipeline_id}"
f"&gitlab_job_id={job_id}"
)