This project is a command-line tool designed to interact with the GitLab API to generate reports on time spent on issues and merge requests within a specific GitLab project.
- Stats Mode: Calculate the total time spent on issues and merge requests.
- Report Mode: Generate a detailed report of time entries.
- GitLab personal access token with appropriate permissions
- Clone the repository:
- Build the project:
go build -o gitlab-time-report
The tool requires several parameters to be passed either via command-line arguments or environment variables:
--modeor-m: The mode of operation, eitherstatsorreport.--token: Your GitLab personal access token.--host: The base URL of the GitLab API.--labels: Labels to filter issues and merge requests (default isany).--project: The ID of the GitLab project.
Example command:
./gitlab-time-report --token YOUR_TOKEN --project YOUR_PROJECT_ID
./gitlab-time-report --token YOUR_TOKEN --project YOUR_PROJECT_ID --labels=BLOCKED
./gitlab-time-report --token YOUR_TOKEN --project YOUR_PROJECT_ID --host https://yourdomain.gitlab.com
./gitlab-time-report --token YOUR_TOKEN --project YOUR_PROJECT_ID --mode stats You can also set the following environment variables instead of passing them as command-line arguments:
TOKEN: Your GitLab personal access token.API_HOST: The base URL of the GitLab API.LABELS: Labels to filter issues and merge requests.PROJECT_ID: The ID of the GitLab project.
The script fetches data from the GitLab API using the provided personal access token and project ID. It retrieves information about time spent on issues and merge requests, filtered by the specified labels.