This script collects open Merge Requests (MRs) from GitLab and syncs them to a Google Sheet. Super useful for tracking bugs, tasks, and stories across projects — all in one place. 📊✨
You’ll need Python 3.8 or later.
pip install requests pandas gspread oauth2client| Library | Purpose |
|---|---|
requests |
Makes HTTP requests to the GitLab API |
pandas |
Handles tabular data, making it easy to format and convert to spreadsheet |
gspread |
Talks to Google Sheets API using Python |
oauth2client |
Manages Google authentication via a service account |
- Visit GitLab → Access Tokens
- Create a token with the following scopes:
read_apiread_repository
- Add it to your script:
GITLAB_TOKEN = "your_personal_access_token"
- Go to Google Cloud Console
- Enable:
- Google Sheets API
- Google Drive API
- Create a Service Account:
- Go to
IAM & Admin → Service Accounts - Create one, and download the JSON key file
- Go to
- Save the file as
credentials.jsonin the same directory as your script
- Open your Google Sheet
- Click Share
- Add the client email from
credentials.json(e.g.[email protected]) - Set permission to Editor
SHEET_ID = "your_google_sheet_id_here"
SHEET_NAME = "Sheet1" # or your tab nameTo find the Sheet ID, grab it from the URL:
https://docs.google.com/spreadsheets/d/<< THIS IS YOUR ID >>/edit#gid=0
Run the script with:
python collect_mrs.pyIf everything is set up correctly, you’ll see:
✅ Google Sheet updated!- Authenticates with GitLab and Google Sheets
- Pulls open MRs from the
mainbranch - Categorizes MRs by type (
[Bug],[Task],[Story]) - Updates the specified tab in your Google Sheet with:
- Project name
- MR title
- URL
- Assignee
- Type
📌 Author Kevin Pham Mobile Engineer · Organic Enthusiast · Automation Lover