Verified Commit 6385b3f2 authored by anarcat's avatar anarcat
Browse files

try to use the job-token properly

We were passing it as a private token, but it needs a special header.
parent 44515fbc
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -82,14 +82,20 @@ def main():
    if args.project_id is None:
        parser.error("missing CI_PROJECT_ID environment, use --project-id to specify")

    token = os.environ.get("GITLAB_PRIVATE_TOKEN")
    if token is None:
        parser.error("missing GITLAB_PRIVATE_TOKEN environment")

    headers = {
        "Content-Type": "application/json",
        "PRIVATE-TOKEN": token,
    }
    ci_job_token = os.environ.get("CI_JOB_TOKEN")
    if ci_job_token:
        headers['JOB-TOKEN'] = ci_job_token

    gitlab_private_token = os.environ.get("GITLAB_PRIVATE_TOKEN")
    if gitlab_private_token:
        headers['PRIVATE-TOKEN'] = gitlab_private_token

    if gitlab_private_token is None and ci_job_token is None:
        parser.error("missing GITLAB_PRIVATE_TOKEN or CI_JOB_TOKEN environment")

    success = True
    for path in args.path:
        logging.info("linting GitLab CI YAML file: %s", path.name)