Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.
/ gitlab2jenkins Public archive

Simple web application which provides a bridge between GitLab and Jenkins CI server. UNMAINTAINED.

License

Notifications You must be signed in to change notification settings

fcelda/gitlab2jenkins

Repository files navigation

gitlab2jenkins

Gitlab2jenkins is a simple web application, which provides a bridge between GitLab and Jenkins CI server.

The application exposes API, which looks the same as API used by GitLab CI server. However all requests are processed and proxied to Jenkins. This is useful especially when your testing infrastructure is complicated and GitLab CI cannot satisfy your requirements — for instance, multi-host builds, triggering of other tasks, etc.

It is written in Ruby (using Sinatra web micro framework) and is ready to be run on OpenShift cloud.

Demo, actually used in production: Knot DNS - gitlab2jenkins at CZ.NIC Labs.

Deployment

Local deployment

Clone the repository, install required gems, edit the configuration, and start the server:

  1. git clone https://github.com/fcelda/gitlab2jenkins.git
  2. cd gitlab2jenkins
  3. bundle install
  4. edit config.rb (provide connection to MySQL database, GitLab URL, and Jenkins URL)
  5. bundle exec foreman start
  6. bundle exec ./web.rb

Deployment on OpenShift

Create the application directly using rhc. Notice that the application requires third party cartridge with Foreman.

rhc app create <appname> ruby-1.9 mysql-5.1 \
http://cartreflect-claytondev.rhcloud.com/reflect?github=ncdc/openshift-foreman-cartridge \
--from-code https://github.com/fcelda/gitlab2jenkins.git

Configuration

Configure target Jenkins job

  1. Create new or update existing target Jenkins job.
  2. In build configuration, enable This build is parametrized checkbox and add two parameters: commit and branch.
  3. Set up source code checkout from GitLab Git repository and use $commit value as a branch to build.
  4. In build triggers, enable Trigger builds remotely and set random Authentication token.

Register Jenkins job in Gitlab2jenkins

Use provided add_project.rb script to register target Jenkins task.

For local deployment, run:

./add_project.rb "Project Name" "jenkins-job-name" "jenkins-secret-token"

For OpenShift deployment, run:

rhc ssh <appname> 'cd app-root/repo && bundle exec ./add_project.rb "Project Name" "jenkins-job-name" "jenkins-secret-token"'

The summary should be printed out. New secret token for authenticate to Gitlab2jenkins will be generated.

Project: Project Name
Jenkins: jenkins-job-name (token jenkins-secret-token)
Token:   gitlab2jenkins-generated-token

Open Gitlab2jenkis in web browser, link to the project should be on the main page.

Configure GitLab to use the proxy

  1. In the project settings in GitLab select Services and GitLab CI.
  2. Enable the service by checking the Activate checkbox.
  3. Set Token token a value generated by add_project.rb script.
  4. Set Project url to project page in Gitlab2jenkins:
    • In case of OpenShift, it will be something like http://<app-name>-<namespace>.rhcloud.com/projects/<project-id>.
    • In case of local deployment, it will be something like http://localhost:4567/projects/<project-id>.

Troubleshooting

New builds are pulled from Jenkins periodically. If it does not work, try updating the builds manually:

./update_builds.rb once or rhc ssh gitlab2jenkins 'cd app-root/repo && bundle exec ./update_builds.rb once'

About

Simple web application which provides a bridge between GitLab and Jenkins CI server. UNMAINTAINED.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages