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.
The following diagrams describe the data flow within the proxy for a received GitHub webhook respectively a direct user interaction with the Jenkins service:
The following paragraphs describe how to build and work with the source.
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 build
$ make image
$ make test
$ make fmt
$ make validate_commits
$ make clean
More help is provided by make help
.
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
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 |
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
[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
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