Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Web appliction that listens to post-hooks from GitLab and tweets about it.
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
config
lib
.gitignore
Gemfile
Gemfile.lock
Procfile
README.md
config.ru
gitlab_hook.rb

README.md

GitLab Hook

  • If you're missing GitHub Twitter hook when using GitLab, you just found a solution.

Installation

Twitter

  • Log into https://dev.twitter.com/apps
  • Click on Create a new application.
  • Fill out everything needed and click on Create your Twitter application.
  • Now in Settings tab, set Access: to Read and Write and save it.
  • Keep this page open or copy all the tokens and keys from Details tab. You'll need them in a while.

Bit.ly

  • If you don't have account on bit.ly, create one.
  • Log into your account, and copy your Api Key from Settings tab.

Your computer

  • Clone this repository: git clone git@github.com:SmartMedia/gitlab-hook.git
  • Create Heroku Cedar application: heroku create <APP_NAME> --stack cedar
  • Setup variables based on your Twitter Details and Bitly Settings tab:
  • For GITLAB_ACCESS_TOKEN use some random string.
heroku config:add \
GITLAB_ACCESS_TOKEN='' \
BITLY_USERNAME='' \
BITLY_API_KEY='' \
TWITTER_CONSUMER_KEY='' \
TWITTER_CONSUMER_SECRET='' \
TWITTER_OAUTH_TOKEN='' \
TWITTER_OAUTH_TOKEN_SECRET=''
  • Put your
  • If you want to test localy, setup the same variables used by application in all *.yml.erb files in config directory.
  • git push heroku

GitLab

  • Open your project.
  • Select Hooks tab.
  • Fill out URL of your Heroku app with access_token parameter. (eg. http://<APP_NAME>.herokuapp.com/?access_token=<GITLAB_ACCESS_TOKEN>)
  • Press "Test Hook"
  • Enjoy your Twitter timeline.

Setting this hook for every project in GitLab

  • SSH to your GitLab server. Navigate to gitlab directory and run rails c production
# If you already have this hook on some project, you can use url = WebHook.first.url
url = 'http://<APP_NAME>.herokuapp.com/?access_token=<GITLAB_ACCESS_TOKEN>'
Project.all.each do |project|
  project.web_hooks << WebHook.create(url: url) if project.web_hooks.empty?
end
Something went wrong with that request. Please try again.