CI Demo - how to create a custom Jenkins Docker image
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
images
ref/init.groovy.d
.gitignore
CHANGELOG.md
Dockerfile
LICENSE.md
README.md
docker-compose.yml
plugins.txt

README.md

JavaScript CI Demo - Jenkins

For the Do-It-Yourself Full Stack JavaScript Continuous Integration (CI) demo, we will use Jenkins as our automation server for builds, tests and deployments. Jenkins is an open-source tool anyone can easily setup.

Beautiful UI with Blue Ocean UI

We will use the Jenkins community image from the Docker Registry.

Use

Clone this repository. And then run:

docker-compose up --build
  • Then you can view Jenkins in your browser at http://localhost:8080/
  • Login with username cidemo and password cidemo.

Jenkins Image

Our Dockerfile has created a custom Jenkins image with two additional features:

  • Chrome browser is installed and is used for unit tests.
  • Cloud Foundry CLI which is used for deployment.

LTS Tag

This demo uses the Long Term Support (LTS) tag, instead of default latest.

FROM jenkins/jenkins:lts

When logged-in, the UI sometimes shows this kind of message appears:

New version of Jenkins (2.121.1) is available for download (changelog).

It may also accompany a warning. This is just a demo. When you customizing your own Jenkins image, you will probably want to be more specific about which tag you choose.

Plugins

We also preloaded our Jenkins with some plugins for our toolchain and an improved workflow:

Skip Startup

These changes were made for convenience of demo presentations:

  • skips setup wizard.
  • sets basic security defaults to avoid warnings on load.

These are not meant as a recommendation! For more about preinstalled configurations, see the official documentation.

Pipelines

Jenkins is an automation server. We define workflows and jobs with pipelines, which can be groovy or a beautiful DSL, for example:

#!/usr/bin/env groovy

pipeline {
    agent any

    options {
        disableConcurrentBuilds()
        timestamps()
    }

    tools {
        nodejs 'node-8'
    }

    parameters {
        string( name: 'APP_BASE_URL',
                defaultValue: 'https://localhost/',
                description: 'App Base URL to run e2e tests against')
    }

    stages {
        stage('Checkout') {
            steps {
                checkout scm
            }
        }

        stage('NPM Install') {
            steps {
                sh 'npm install'
            }
        }

        stage('E2E Tests') {
            environment {
                APP_BASE_URL = "$params.APP_BASE_URL"
            }

            steps {
                sh 'npm run e2e:prod'
            }
        }
    }
}

It is that simple to define a pipeline using the Jenkins Declarative Pipeline Syntax.