GitLab Issues Exporter is a Python tool designed to export issues from a GitLab project into a user-friendly HTML format. It captures all essential information, including issue descriptions, comments, and attachments, making it easy to create offline archives, generate technical documentation, or migrate data.
- Flexible Export Options: Configure the tool to export all issues or a specific list of issues by their IDs.
- State Filtering: Filter issues by their state (e.g.,
opened,closed, orall). - Complete Data Capture: Exports issue details, comments, and downloads all associated attachments.
- HTML Rendering: Converts GitLab's Markdown syntax into clean, readable HTML files.
- Navigable Index: Automatically generates an
index.htmlfile for easy browsing of all exported issues. - Easy Configuration: All settings are managed through a
config.yamlfile and a.envfile for sensitive data like API tokens.
- Python 3.8 or newer.
- A GitLab Private Access Token with
apiscope.
-
Clone the Repository:
git clone <your-repository-url> cd issues_exporter
-
Create and Activate a Virtual Environment:
# Create the virtual environment python -m venv .venv # Activate it (Windows) .venv\Scripts\activate # Activate it (macOS/Linux) # source .venv/bin/activate
-
Install Dependencies:
pip install -r requirements.txt
-
Configure Environment Variables:
Copy the example
.envfile:copy .env.example .env
Open the new
.envfile and add your GitLab Private Access Token:GITLAB_PRIVATE_TOKEN="your_gitlab_token_here" -
Configure the Export:
Copy
config.example.yamltoconfig.yamland customize it with your project details. You can specify the GitLab project ID and choose which issues to export.Example
config.yaml:gitlab: api_base_url: "https://gitlab.com/api/v4" project_id: 12345678 # Your GitLab project ID export: output_dir: "exported_issues" # Use "all" to export all issues or provide a list of issue IDs: [1, 5, 10] issues_to_export: "all" # Filter by state: "opened", "closed", or "all" state: "opened"
-
Run the Exporter:
Execute the main script from the project's root directory:
python main.py
-
Check the Output:
The exported HTML files and attachments will be saved in the directory specified by
output_dirin your configuration (e.g.,exported_issues/).
issues_exporter/
├── .env
├── .env.example
├── .gitignore
├── config.yaml
├── config.example.yaml
├── exporter.py
├── gitlab_client.py
├── html_renderer.py
├── main.py
├── README.md
└── requirements.txt
| Section | Parameter | Description |
|---|---|---|
gitlab |
project_id |
The ID of your GitLab project. |
export |
output_dir |
The folder where exported files will be saved. |
issues_to_export |
Set to "all" or a list of issue IDs (e.g., [1, 2]). |
|
state |
Filters issues by state: opened, closed, all. |
| Variable | Description |
|---|---|
GITLAB_PRIVATE_TOKEN |
Your GitLab Private Access Token. |
- Authentication Errors: Ensure your
GITLAB_PRIVATE_TOKENin the.envfile is correct and has the necessaryapipermissions. - Project Not Found: Double-check that the
project_idinconfig.yamlis correct. - File Not Found Errors: Make sure you are running
python main.pyfrom the root directory of the project.
Contributions are welcome! If you have suggestions for improvements or find any issues, please feel free to open an issue or submit a pull request.
This project is unlicensed. You are free to use, modify, and distribute it as you see fit. Consider adding a LICENSE file if you plan to share it publicly.