This project is not covered by Drupal’s security advisory policy.

Introduction

This module fetches and parses specially created comments from a Gitlab installation and extracts time tracking information from this.
Thanks to that, we can track work time spent on different tickets managed by Gitlab.
The goal of this module is to improve general time tracking in Gitlab CE, as it's far from being perfect.

This module uses the migrate module and custom Gitlab API client for maintaining import process.

Why not to use built-in "/spent" gitlab command?

The answer is in limited nature of "/spend" command and API exposed by gitlab.
It allows only to add / remove time to the total time spent on particular issue.
What is missing here is possibility to add some comment and custom date. So main reason behind this is need to have more complex time tracking reports, which is currently lacking in Gitlab (CE) version.

refs:
https://docs.gitlab.com/ee/user/project/time_tracking.html

Output from gitlab API is not detailed:
refs:

{
  "human_time_estimate": "2h",
  "human_total_time_spent": "1h",
  "time_estimate": 7200,
  "total_time_spent": 3600
}

So the main reason why is limitation behind built-in gitlab facilities. What is important, is fact, that we are using built-in gitlab time tracker. After parsing all comments with custom time tracking, we also update (using Gitlab API) summary of work spent on this particular ticket.

Installation and configuration.

In order to use this module, please enable
- gitlab_time_tracker
- gitlab_time_tracker_migration
- gitlab_time_tracker_views_pack (optional) module.
- gitlab_time_tracker_users (optional, if you want use gitlab as oauth2 provider) module.

In order to make integration working, you need to add two lines to your settings.php file:

$settings['gitlab'] = [
  'api_token' => 'API TOKEN',
  'url' => 'https://URL TO YOUR GITLAB INSTALLATION/api/v4/',
  'client_secret' => CLIENT_SECRET, (OAUTH integration)
  'client_id' => 'CLIENT_ID', (OAUTH integration)
];

You can generate API key at "https://URL TO YOUR GITLAB INSTALLATION/profile/personal_access_tokens" page. Please note, that API will use permission of a user, that had generated token, so it will also affect list of visible projects, issues etc.

OAUTH integration

If you want to execute calls as gitlab user instead of global api token, please register API at [GITLAB URL]/admin/applications. Please make sure that in callbacks, you have following URL: [DRUPAL URL]/gitlab_time_tracker/authenticate.

After that, you can use block provided by gitlab_time_tracker_users that includes link to authentication callback to authenticate users using their gitlab accounts.

Usage

This module periodically (in cron) fetches list of projects and users. When it propagated, at "/projects" subpage of your Drupal installation, you can select projects and execute "Refresh project timesheet information". This will fetch all issues for selected projects, and parses comments belonging to fetched issues.

After that, it will try to find comments in form ":clock1: 8h | 2018-01-12 | What I have done". Other allowed forms:
- ":clock1: 1h 25m | What I have done"
- ":clock1: 1h 25m"

If you enabled gitlab_tracker_views_pack module, you can check timetrack reports at page projects/PROJECT_ID/timetrack, alternatively, you can check user/USER_ID/timetrack

Roadmap

- Using Gitlab as an authentication provider DONE.
- Using API token from an authenticated user, not a global one DONE.
- Adding support for milestones
- Charts and monthly reports.
- Performance optimisation.
- Improving quality of code. Stable release.

Supporting organizations: 
Sponsorship.

Project information

  • caution Minimally maintained
    Maintainers monitor issues, but fast responses are not guaranteed.
  • Created by jsobiecki on , updated
  • shield alertThis project is not covered by the security advisory policy.
    Use at your own risk! It may have publicly disclosed vulnerabilities.

Releases