Git Product home page Git Product logo

fabric8-jenkins-proxy's Introduction

fabric8-jenkins-proxy Build Status Build Status

What is it?

fabric8-jenkins-proxy (Jenkins Proxy) is the sister project to fabric8-jenkins-idler(Jenkins Idler). Its task is to run a HTTP Proxy which sits in between an openshift.io user and its Jenkins instance within openshift.io. For more information refer to the Idler README.

Architectural Diagram

Data flow diagrams

The following diagrams describe the data flow within the proxy for a received GitHub webhook respectively a direct user interaction with the Jenkins service:

GitHub Webhook

Jenkins UI

How to build?

The following paragraphs describe how to build and work with the source.

Prerequisites

The project is written in Go, so you will need a working Go installation (Go version >= 1.9.1).

The build itself is driven by GNU Make which also needs to be installed on your systems.

Last but not least, you need a running Docker daemon, since the final build artifact is a Docker container.

Make usage

Compile the code

$ make build

Build the container image

$ make image

Run the tests

$ make test

Format the code

$ make fmt

Check commit message format

$ make validate_commits

Clean up

$ make clean

More help is provided by make help.

Dependency management

The dependencies of the project are managed by Dep. To add or change the current dependencies you need to delete the Dep lock file (Gopkg.lock), update the dependency list (Gopkg.toml) and then regenerate the lock file. The process looks like this:

$ make clean
$ rm Gopkg.lock
# Update Gopkg.toml with the changes to the dependencies
$ make build
$ git add Gopkg.toml Gopkg.lock
$ git commit

Continuous Integration

At the moment Travis CI and CentOS CI are configured. Both CI systems build all merges to master as well as pull requests.

CI System
CentOS CI master, pr
Travis CI master, pr

Running locally

The repository contains a script setupLocalProxy.sh which can be used to run the Proxy locally. A prerequisite for this is access to https://console.rh-idev.openshift.com/. To run the script you need to export your OpenShift access token for console.rh-idev.openshift.com as DSAAS_PREVIEW_TOKEN. Note, In order to port forward you need to edit permissions on the dsaas-preview namespace. You need to have jq installed to run these commands. For fedora use sudo dnf install jq

Usage: ./scripts/setupLocalProxy.sh [start|stop|env|unset]

This script is used to run the Jenkins Proxy on localhost. As a prerequisite OPENSHIFT_API_TOKEN needs to be exported. In your shell (from the root of fabric8-jenkins-proxy):

To start proxy and other required services

[user@localhost ~]$ export DSAAS_PREVIEW_TOKEN=<dsaas-preview-token> 
[user@localhost ~]$ ./scripts/setupLocalProxy.sh start 

Run command below this in a seperate terminal so that we can see logs of the above command.

[user@localhost ~]$ export DSAAS_PREVIEW_TOKEN=<dsaas-preview-token> 
[user@localhost ~]$ eval $(./scripts/setupLocalProxy.sh env) 
[user@localhost ~]$ fabric8-jenkins-proxy 

After you stop fabric8-jenkins-proxy, you would want to stop all the dependency services as well To remove postgres container and stop port-forwarding to prod-preview's idler service and tenant service

[user@localhost ~]$ ./scripts/setupLocalProxy.sh stop

Services running as a part of this local setup:

  • idler on 9001
  • tenant service on 9002
  • postgres on 5432

Testing webhooks

You can trigger local webhook delivery like so. Go to a GitHub repository generated by the OpenShift.io launcher. Find the webhook settings under Settings->Webhooks. There you can see the recent deliveries. Copy the payload of a webhook delivery into a file webhook-payload.json. Then execute the following curl command:

$ curl http://localhost:8080/github-webhook/ \
-H "Content-Type: application/json" \
-H "User-Agent: GitHub-Hookshot/c494ff1" \
-H "X-GitHub-Event: status" \
-d @webhook-payload.json

Testing Through UI

Any request that is made to proxy(i.e., port 8080) regardless of the path, proxy will send a request to idler to unidle jenkins, if it is idled.

curl http://localhost:8080/*

This would show a spinning wheel until jenkins is idle. On running locally the html page might not exist so, it will show a message on not finding the html page.

APIs

This project opens two ports 9091 and 8080. Proxy runs on 8080 and API router runs 9091. The API router has only one API, which is info API. An example is as follows

Request: GET http://localhost:9091/api/info/ksagathi-preview

Response: {"namespace":"ksagathi-preview","requests":0,"last_visit":0,"last_request":0}

fabric8-jenkins-proxy's People

Contributors

chmouel avatar hferentschik avatar jmelis avatar kishansagathiya avatar lordofthejars avatar sthaha avatar vpavlin avatar

Watchers

 avatar  avatar

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.