Skip to content

Instantly share code, notes, and snippets.

@MBM1607
Last active January 1, 2024 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MBM1607/daa0d154a4bc041dfc754c26679aef33 to your computer and use it in GitHub Desktop.
Save MBM1607/daa0d154a4bc041dfc754c26679aef33 to your computer and use it in GitHub Desktop.
github-integration-with-scheduler

GitHub Integration With Scheduler

This is a Plugin for one-way integration between GitHub & Redmine. This plugin has a scheduled task that can run at a customizable interval to fetch all projects & issues from a GitHub account and save them in Redmine.

Features

  • Syncs GitHub projects with Redmine projects
  • Syncs GitHub issues in each project with Redmine issues in the corresponding project
    • Syncs GitHub issue comments with Redmine issue notes
    • Syncs GitHub issue assignee with Redmine issue assignee

Requirements

This plugin requires Redmine 5.0.0 or higher. The previous versions of Redmine are not supported. The plugin is tested with Redmine 5.1.1, but it should work with any Redmine version that uses Rails 6.x or higher.

Credentials

The personal access token must be created from Github Developer Settings.

The following permissions are required:

Repository permissions

  • Issues - Access: Read-Only - to read issues
  • Metadata - Access: Read-Only - Mandatory in order to be able to read Issues

Organization permissions

  • Projects - Access: Read-Only - to read projects

Setup

1. Install the plugin

  1. Clone the plugin source code into plugins/github_integration:

    git clone `https://github.com/techhive-solutions/redmine-github-integration` `plugins/github_integration`
  2. Switch to branch scheduler:

    cd plugins/github_integration
    git checkout scheduler
    cd -
  3. Install the dependencies bundle install

  4. Migrate the database bundle exec rake redmine:plugins:migrate

2.1 Prerequisites

Install Redis Server & run it

2.2 Setup Sidekiq

Add the gem as dependency in Gemfile.local file. If the file doesn't exist, you need to create it.

  gem 'sidekiq'

Run bundle install to install the gem

2.3 Configure Sidekiq

Create a config file config/sidekiq.yml with the following content:

  ---
  :logfile: log/sidekiq.log
  :queues:
  - mailers
  - default
  :scheduler:
    :dynamic: true

2.4 Configure Redmine to use Sidekiq

Create config/additional_environment.rb file if the file does not exist by copying the existing example file:

  cp config/additional_environment.rb.example config/additional_environment.rb

Add the following line to the config/additional_environment.rb file:

config.active_job.queue_adapter = :sidekiq

Restart Redmine to apply the changes

2.5 Test the configuration

Browse to Information tab from Redmine Administration page and check the mailer queue value:

  Mailer queue                   ActiveJob::QueueAdapters::SidekiqAdapter

2.6 Start Sidekiq as a service

  1. Follow the official steps described in https://github.com/mperham/sidekiq/wiki/Deployment#running-your-own-process

  2. The above steps points to a sidekiq.service example file which can be used to configure the service

  3. During service configuration, at least the following information must be provided:

    1. WorkingDirectory
    2. User
    3. Group
  4. Enable and start the service

     sudo systemctl enable sidekiq
     sudo systemctl start sidekiq
  5. Test again the configuration as described in 2.5

3. Configure the plugin

  1. Restart Redmine
  2. Go to Administration > Plugins > GitHub Integration plugin > Configure
  3. Enter the GitHub credentials:
    1. Enter the GitHub organization name
    2. Enter the GitHub personal access token, created as per the Credentials section
  4. Enter the sync interval in hours
  5. Click Apply
  6. This saves the settings but the sync is not started yet.
  7. In the Schedule the Sync Process section, click Schedule Now to schedule the process.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment