- Python 3.x
requests
library
import os
import requests
import json
The following Python code demonstrates how to trigger a pipeline in a GitLab project using the GitLab API. Additionally, this approach allows you to insert custom variables into the pipeline:
import requests
import json
def start_pipeline(project_id, token, ref, var1, var2, var3):
url = f"https://gitlab.com/api/v4/projects/{project_id}/trigger/pipeline"