/fabric8-jenkins-idler

OpenShift.io service to idle resp.unidle Jenkins instances

Primary LanguageGoApache License 2.0Apache-2.0

Jenkins Idler Build Status Build Status

What is it?

The Jenkins Idler is a service which idles perspectively unidles a tenant's Jenkins instance. In order to determine whether a Jenkins instance can be idled, the Idler monitors OpenShift Build and DeploymentConfig changes. It also keeps track of direct access to the UI as well as GitHub webhook deliveries.

Idler Architecture

  1. Idler watches Build and DeploymentConfig changes in OpenShift
  2. Idler controls the state of Jenkins DeploymentConfig in OpenShift
  3. Idler is checking Jenkins Proxy for number of buffered webhook requests and last access to Jenkins UI
  4. Proxy caches webhook requests while Jenkins is un-idling

Jenkins Idler is the sister project to fabric8-jenkins-proxy(Jenkins Proxy).

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

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. Also of the unit tests make use of Docker.

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 setupLocalIdler.sh which can be used to run the Idler 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, you need edit permissions on the dsaas-preview namespace in order to port forward. You also need to make sure to limit the Idler feature to a specific set of users by setting JC_FIXED_UUIDS to a comma separated list of dedicated user UUIDs. For more information refer to help of setupLocalIdler.sh itself.

Misc

How to contribute?

If you want to contribute, make sure to follow the contribution guidelines when you open issues or submit pull requests.