Giter Club home page Giter Club logo

jenkins's Introduction

Autopilot Pattern Jenkins

This repo is an extension of the official Jenkins Docker image, designed to be self-operating according to the autopilot pattern. This application demonstrates support for building containers via Joyent's Triton and for provisioning Jenkins slaves via Triton.

DockerPulls DockerStars

Design

One of the most important aspects of CI is ensuring that the CI system itself is secured, but including credentials to the build system in the container image leaves us open to accidental disclosure. This architecture injects credentials via environment variables and then uses a ContainerPilot preStart handler to update the appropriate files required by Jenkins.

Another design constraint is that CI systems often become "pets not cattle," which results in disruption to deployments if the Jenkins server is broken. We can take advantage of ContainerPilot to have a Jenkins instance bootstrap its job configuration from GitHub during the preStart handler.

The first-run.sh script called by the preStart handler will create a new job called "jenkins-jobs". When triggered, this job pulls a workspace from a git repository passed in the GITHUB_JOBS_REPO environment variable and from that repo creates new jobs from each configuration it can find in the workspace's jobs/ directory. Existing jobs will be updated from the remote repo.

Caveats

Jenkins requires SSL to be operated securely. You should only run Jenkins behind a reverse proxy that supports SSL (ex. Nginx). If you are running Jenkins in a private network, you'll want to replace the following section of the job-building job found at usr/share/jenkins/templates/jenkins-jobs.config.xml in this repo.

<triggers>
  <com.cloudbees.jenkins.GitHubPushTrigger plugin="[email protected]">
    <spec></spec>
  </com.cloudbees.jenkins.GitHubPushTrigger>
</triggers>

This configures the job-building job to receive GitHub webhooks to fire off the job when the remote repository receives a push. Jenkins will verify the hook is legitimate by sending a request back to GitHub, but this communication should be over SSL in both directions. If your environment cannot support this, you may want to poll the git repository for changes instead:

<triggers>
  <hudson.triggers.SCMTrigger>
    <spec>H/15 * * * *</spec>
    <ignorePostCommitHooks>false</ignorePostCommitHooks>
  </hudson.triggers.SCMTrigger>
</triggers>

This configuration polls the repository every 15 minutes.

Run it!

  1. Get a Joyent account and add your SSH key.
  2. Install the Docker Toolbox (including docker and docker-compose) on your laptop or other environment, as well as the Joyent Triton CLI (triton replaces our old sdc-* CLI tools)
  3. Configure Docker and Docker Compose for use with Joyent:
curl -O https://raw.githubusercontent.com/joyent/sdc-docker/master/tools/sdc-docker-setup.sh && chmod +x sdc-docker-setup.sh
./sdc-docker-setup.sh -k us-east-1.api.joyent.com <ACCOUNT> ~/.ssh/<PRIVATE_KEY_FILE>

Check that everything is configured correctly by running ./setup.sh. This will check that your environment is setup correctly and will create an _env file that includes the credentials and variables that we'll inject into the Jenkins container. You may wish to edit this file with a password for the Jenkins default admin user.

jenkins's People

Contributors

tgross avatar dekobon avatar misterbisson avatar

Watchers

James Cloos avatar Rajasekhar Balusupati 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.