Skip to content

Instantly share code, notes, and snippets.

View niklash-dev's full-sized avatar

Niklas niklash-dev

View GitHub Profile
@niklash-dev
niklash-dev / start_pipeline.md
Last active August 17, 2023 18:45
Trigger a Pipeline with custom variables in a GitLab Project using Python and the GitLab API

Trigger a Pipeline with custom variables in a GitLab Project using Python and the GitLab API

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"
@niklash-dev
niklash-dev / Get_Azure_Token_with_SP_in_Python.md
Created August 30, 2023 13:10
Get Azure Token using Service Principal (SP) in Python

Requirements

  • Python 3.x
  • requests library

Code Snippet

import os
import requests
import json