A Python script to search and filter GitLab pipelines by task name, environment, status, date, and user who triggered the pipeline.
- Filter pipelines by task name
- Filter by environment (development, test, uat, production)
- Filter by pipeline status (created, pending, success, failed, canceled)
- Filter by date range (updated before/after specific dates)
- Filter by username who triggered the pipeline
- Combine multiple filters for precise searching
-
Download Python:
- Visit Python's official website
- Download the latest Python 3.x version (3.6 or higher)
-
Install Python:
# Windows (During installation, make sure to check "Add Python to PATH") # Run in Command Prompt to verify installation python --version # macOS (Using Homebrew) brew install python3 python3 --version # Linux - Ubuntu/Debian sudo apt update sudo apt install python3 python3 --version # Linux - CentOS/RHEL sudo yum install python3 python3 --version
-
Windows:
# Python 3.x comes with pip by default. Verify installation: pip --version # If pip is not installed: curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py python get-pip.py
-
macOS:
# Using Homebrew (pip included if Python installed via Homebrew) brew install python3 # Verify pip installation pip3 --version # If pip is not installed curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py python3 get-pip.py
-
Linux:
# Ubuntu/Debian sudo apt update sudo apt install python3-pip pip3 --version # CentOS/RHEL sudo yum install python3-pip pip3 --version
- GitLab access token with appropriate permissions
- Project ID of the GitLab repository
-
Clone the repository:
git clone git@github.com:mahadmughal/gitlab_pipeline_lookup_tool.git cd gitlab_pipeline_lookup_tool
-
Create a virtual environment:
# Windows python -m venv venv .\venv\Scripts\activate # macOS/Linux python3 -m venv venv source venv/bin/activate
-
Install the required packages:
pip install -r requirements.txt
-
Create a
.env
file in the root directory:touch .env
-
Add your GitLab credentials to the
.env
file:PROJECT_ID=your_project_id GITLAB_ACCESS_TOKEN=your_gitlab_token GITLAB_USERNAME=your_gitlab_username GITLAB_PASSWORD=your_gitlab_password GITLAB_BASE_URL=your_gitlab_base_url
The script supports various filtering options that can be used individually or combined:
python3 get_specific_pipeline.py --task-name "NEOP-20473"
python3 get_specific_pipeline.py --task-name "NEOP-20473" --environment production
python3 get_specific_pipeline.py --task-name "NEOP-20473" --status success
# Pipelines updated before a specific date
python3 get_specific_pipeline.py --task-name "NEOP-20473" --updated-before 2025-02-13
# Pipelines updated after a specific date
python3 get_specific_pipeline.py --task-name "NEOP-20473" --updated-after 2025-02-13
python3 get_specific_pipeline.py --task-name "NEOP-20473" --username 'm.asif'
python3 get_specific_pipeline.py --task-name "NEOP-20473" \
--environment uat \
--status failed \
--updated-before 2025-02-13 \
--updated-after 2025-02-13 \
--username 'm.asif'
Filter | Description | Available Options |
---|---|---|
--task-name |
Search for specific task (Required) | Any string |
--environment |
Filter by environment | development, test, uat, production |
--status |
Filter by pipeline status | created, pending, success, failed, canceled |
--updated-before |
Show pipelines updated before date | YYYY-MM-DD format |
--updated-after |
Show pipelines updated after date | YYYY-MM-DD format |
--username |
Filter by user who triggered pipeline | GitLab username |
The script returns pipeline information including:
- Pipeline ID
- Status
- Creation date
- Last update date
- Triggered by (username)
- Environment
- Pipeline name
- Result status
The script includes error handling for:
- Invalid date formats
- Connection issues
- Authentication failures
- Invalid project IDs
- API rate limiting
Contributions are welcome! Please feel free to submit a Pull Request.