Giter Site home page Giter Site logo

jollychang / gitlab2jenkins Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fcelda/gitlab2jenkins

0.0 2.0 0.0 122 KB

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

License: MIT License

Shell 0.50% Ruby 99.50%

gitlab2jenkins's Introduction

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. foreman start

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>.

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'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.