Wilson Mar bio photo

Wilson Mar

Hello!

Calendar YouTube Github

LinkedIn

Make your robot butler for CI/CD DevOps

US (English)   Norsk (Norwegian)   Español (Spanish)   Français (French)   Deutsch (German)   Italiano   Português   Estonian   اَلْعَرَبِيَّةُ (Egypt Arabic)   Napali   中文 (简体) Chinese (Simplified)   日本語 Japanese   한국어 Korean

Overview

This tutorial aims to succinctly present step-by-step instructions to setup Jenkins on Mac OSX and CentOS, both locally and in various cloud environments.

I want you to feel confident that you’ve mastered this skill. That’s why this takes a hands-on approach where you type in commands and we explain the responses and possible troubleshooting. This is a “deep dive” because all details are presented.

Like a good music DJ, I’ve carefully arranged the presentation of concepts into a sequence for easy learning, so you don’t have to spend as much time as me making sense of the flood of material around this subject.

Sentences that begin with PROTIP are a high point of this website to point out wisdom and advice from experience. NOTE point out observations that many miss. Search for them if you only want “TL;DR” (Too Long Didn’t Read) highlights.

Stuck? Contact me and I or one of my friends will help you.

Jenkins invokes other programs (maven scripts, build, Selenium, JMeter, etc.) for building software, conducting tests, etc.

Jenkins can invoke jobs on a schedule, but it’s called a “continuos integration” (CI) tool because it can invoke jobs when a trigger is fired.

Jenkins can orchestrate a chain of tasks that kicks off each step in sequence based on the ending status of the previous step, such as to ensure that components already unit-tested can be integrated together.

For scaling, several slaves can be setup to run simultaneously.

Alternatives to Jenkins

Jenkins originated in 2005 as a simple CI site which Kohsuke Kawaguchi called “Hudson”. As a Sun employee creation, Hudson was among copyrights acquired by Oracle Corporation in 2010. At that time, the community forked the open-source project on java.net as “Jenkins” for the Eclipse Foundation to acquire in 2011. Development on Hudson ceased in 2016. See * and *

https://www.harness.io/blog/chaos-engineering-with-jenkins

Prerequisites: Java

Jenkins is open-source software written in Java. So you’ll need to first install Java 1.5 or higher.

If you download Jenkins, it’s a jenkins.war file.

It contains a Tomcat web server Java runs under.

Installation options

From the easiest to the most effort:


Cloudbees Cloud No Installation

Installation is not necessary if you use Cloudbees.com which hosts Jenkins in their cloud.

Their CEO is Kohsuke Kawaguchi (@kohsukekwa, kk@kohsuke.org) who invented Hudson/Jenkins. Hear him speak at this Oct, 2014 meetup about Workflow.

Cloudbees sells Nectar, a supported and enhanced on-premise version of Jenkins that automatically scales on VMWare virtual machines. Cloudbees has a professional certification exam on this product.

https://www.cloudbees.com/blog/how-to-install-and-run-jenkins-with-docker-compose

docker run -it -p 8080:8080 jenkins/jenkins:lts

  1. Create a bridge network in Docker using the following docker network create command:

    docker network create jenkins
  2. https://hub.docker.com/r/cloudbees/workflow-demo
    is the demo Docker image for Jenkins workflow with Jenkins Enterprise by CloudBees proprietary extension for checkpoint.

    docker run -p 8080:8080 -p 8081:8081 -p 8022:22 -p 9418:9418 -ti cloudbees/workflow-demo

    See Port forwardings

  3. To keep data after reboot, set up a volume to start the Jenkins instance data:

    https://www.cloudbees.com/blog/how-to-install-and-run-jenkins-with-docker-compose

https://livebook.manning.com/book/pipeline-as-code/chapter-14/v-4/1 “Pipeline as Code” book

https://gist.github.com/ivdunin/cd536db94860076872dd6d2c60c80fa0

https://github.com/wardviaene/jenkins-course/blob/master/docker-compose/docker-compose.yml

Local Docker install

Assuming you have Docker installed on your local machine:

  1. Download and use the jenkinsci/workflow-demo Docker image from DockerHub. It’s based on
    this is the open source version of Jenkins.

    docker run –rm -p 2222:2222 -p 8090:8080 -p 8081:8081 -p 9418:9418 -ti jenkinsci/workflow-demo

    The response can take a long time.

    The --rm option tells Docker to automatically clean up the container and remove the file system when the container exits, according to Docker reference, which describes many other options.

    Also, many add --name to spacify a name to the container.

    Port forwardings

    NOTE: The long form of -p is --publish to the Docker container.

    Jenkins runs on port 8090 reassigned from the default 8080 port.

    PROTIP: Remember that the reassigned port to to the left of the default port.

    The Jetty web service runs on port 8081.

    Port 2222 is to access the Jenkins CLI.

    Port 8022:22 is SSH to securely access Git repositories.

    Port 9418 is to use the Git protocol which is similar to SSH, but with no authentication. Thus it’s often the fastest network transfer protocol available, but for read-only (no pushing to it). However, the need to open a special port makes this rare for enterprise use.

    The response are logs that start out like this:

    Running from: /usr/share/jenkins/jenkins.war
    webroot: EnvVars.masterEnvVars.get("JENKINS_HOME")
    Sep 02, 2016 1:21:46 AM org.eclipse.jetty.util.log.JavaUtilLog info
    INFO: Logging initialized @845ms
    Sep 02, 2016 1:21:46 AM winstone.Logger logInternal
    INFO: Beginning extraction from war file
    Sep 02, 2016 1:21:49 AM org.eclipse.jetty.util.log.JavaUtilLog warn
    WARNING: Empty contextPath
    Sep 02, 2016 1:21:49 AM org.eclipse.jetty.util.log.JavaUtilLog info
    INFO: jetty-9.2.z-SNAPSHOT
    Jenkins home directory: /var/jenkins_home found at: EnvVars.masterEnvVars.get("JENKINS_HOME")
    

    Then this appears in the log:

    *************************************************************
    *************************************************************
    *************************************************************
     
    Jenkins initial setup is required. An admin user has been created and a password generated.
    Please use the following password to proceed to installation:
     
    db1b32b17f8d4c3c8d6c9db0cd893a14
     
    This may also be found at: /var/jenkins_home/secrets/initialAdminPassword
     
    *************************************************************
    *************************************************************
    *************************************************************
    
  2. Highlight the password and press Ctrl+C to copy it to your invisible Clipboard.

  3. Open an internet browser to the host and port specified, such as:

    localhost:8090

  4. Proceed to Unlock Admin password in this tutorial.

    Password file

  5. Specify the folder containing passwords (a file which is not in the repo):

    -v `pwd`:/app

    Confirm:

    docker ps -a

    Sample response:

    CONTAINER ID        IMAGE                     COMMAND                  CREATED             STATUS                  PORTS                                                                                         NAMES
    b5e3d39ed158        jenkinsci/workflow-demo   "/bin/tini -- /usr/lo"   12 hours ago        Up 23 minutes           0.0.0.0:2222->2222/tcp, 0.0.0.0:8080-8081->8080-8081/tcp, 0.0.0.0:9418->9418/tcp, 50000/tcp   reverent_swanson
    
  6. To kill a container, specify its container ID from the previous command:

    docker kill b5e3d39ed158

  7. TODO: See how much memory the container is taking when idle:


Digital Ocean SaaS

  1. Sign up for an account at
    https://www.digitalocean.com

  2. Instantiate a CentOS droplet (instance) per this doc (Centos with 512 MB, SFO 2).

  3. Click on the name of the droplet listed (such as “centos-512mb-sfo2-01”).

  4. Click Access, then “Reset Root Password”.

  5. Copy the password and paste it to a safe place.

  6. Click on the IP address.

  7. Login:

    ssh root@138.68.1.138

    Alternately, for Windows, use Putty.

    The authenticity of host '138.68.1.138 (138.68.1.138)' can't be established.
    ECDSA key fingerprint is SHA256:vwQzKkAHmgwCouPC8wY3qEimOMj+etG/35GMRQKrD28.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added '138.68.1.138' (ECDSA) to the list of known hosts.
    root@138.68.1.138's password:
    
  8. Type in the password you specified to use DO:

    You are required to change your password immediately (root enforced)
    Last failed login: Wed Jul 27 19:14:36 UTC 2016 from 40.113.109.51 on ssh:notty
    There were 4544 failed login attempts since the last successful login.
    Last login: Wed Jul 20 20:00:36 2016
    Changing password for root.
    (current) UNIX password:
    New password:
    Retype new password:
    
  9. Type in another made-up (strong) password. Twice.

    Copy and paste these steps to run all steps at once:

    If you want to add users see this.

    The shell script to do the manual steps below automatically:

    
    # Install Java:
    sudo yum -y install java
    # Verify java install:
    java -version
    # Download Jenkins from the Red Hat repo:
    sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
    # Import the verification key using the package manager RPM:
    sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
    # Install Jenkins by running:
    sudo yum install jenkins
    # Input Y
    # Start Jenkins as a service:
    sudo systemctl start jenkins.service
    # Check the status of the service:
    sudo systemctl status jenkins.service
    # TODO: Add IP address of server:
    # Open browser to http://138.68.1.138:8080
    

    There are two basic ways to install Jenkins on CentOS: through a repository, or repo, and via a Java WAR file. Installing from a repo is the preferred method.

    Install Java

  10. Install latest version of Java (JDK which Jenkins uses):

    sudo yum -y install java

    The response:

    Failed to set locale, defaulting to C
    Loaded plugins: fastestmirror
    base                                                     | 3.6 kB     00:00
    extras                                                   | 3.4 kB     00:00
    updates                                                  | 3.4 kB     00:00
    updates/7/x86_64/primary_db                                | 5.7 MB   00:00
    Loading mirror speeds from cached hostfile
            * base: mirror.n5tech.com
            * extras: mirror.pac-12.org
            * updates: mirror.math.princeton.edu
    Resolving Dependencies
    --> Running transaction check
    ---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.101-3.b13.el7_2 will be installed
    --> Processing Dependency: java-1.8.0-openjdk-headless = 1:1.8.0.101-3.b13.el7_2 for package: 1:java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64
    --> Processing Dependency: xorg-x11-fonts-Type1 for package: 1:java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64
    --> Processing Dependency: libpng15.so.15(PNG15_0)(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64
    --> Processing Dependency: libjvm.so(SUNWprivate_1.1)(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64
    --> Processing Dependency: libjli.so(SUNWprivate_1.1)(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64
    --> Processing Dependency: libjava.so(SUNWprivate_1.1)(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64
    --> Processing Dependency: libasound.so.2(ALSA_0.9.0rc4)(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64
    --> Processing Dependency: libasound.so.2(ALSA_0.9)(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64
    --> Processing Dependency: fontconfig for package: 1:java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64
    --> Processing Dependency: libpng15.so.15()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64
    --> Processing Dependency: libjvm.so()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64
    --> Processing Dependency: libjli.so()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64
    --> Processing Dependency: libjava.so()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64
    --> Processing Dependency: libgif.so.4()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64
    --> Processing Dependency: libawt.so()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64
    --> Processing Dependency: libasound.so.2()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64
    --> Processing Dependency: libXtst.so.6()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64
    --> Processing Dependency: libXrender.so.1()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64
    --> Processing Dependency: libXi.so.6()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64
    --> Processing Dependency: libXext.so.6()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64
    --> Processing Dependency: libX11.so.6()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64
    --> Running transaction check
    ---> Package alsa-lib.x86_64 0:1.0.28-2.el7 will be installed
    ---> Package fontconfig.x86_64 0:2.10.95-7.el7 will be installed
    --> Processing Dependency: fontpackages-filesystem for package: fontconfig-2.10.95-7.el7.x86_64
    ---> Package giflib.x86_64 0:4.1.6-9.el7 will be installed
    --> Processing Dependency: libSM.so.6()(64bit) for package: giflib-4.1.6-9.el7.x86_64
    --> Processing Dependency: libICE.so.6()(64bit) for package: giflib-4.1.6-9.el7.x86_64
    ---> Package java-1.8.0-openjdk-headless.x86_64 1:1.8.0.101-3.b13.el7_2 will be installed
    --> Processing Dependency: tzdata-java >= 2015d for package: 1:java-1.8.0-openjdk-headless-1.8.0.101-3.b13.el7_2.x86_64
    --> Processing Dependency: lksctp-tools for package: 1:java-1.8.0-openjdk-headless-1.8.0.101-3.b13.el7_2.x86_64
    --> Processing Dependency: jpackage-utils for package: 1:java-1.8.0-openjdk-headless-1.8.0.101-3.b13.el7_2.x86_64
    ---> Package libX11.x86_64 0:1.6.3-2.el7 will be installed
    --> Processing Dependency: libX11-common >= 1.6.3-2.el7 for package: libX11-1.6.3-2.el7.x86_64
    --> Processing Dependency: libxcb.so.1()(64bit) for package: libX11-1.6.3-2.el7.x86_64
    ---> Package libXext.x86_64 0:1.3.3-3.el7 will be installed
    ---> Package libXi.x86_64 0:1.7.4-2.el7 will be installed
    ---> Package libXrender.x86_64 0:0.9.8-2.1.el7 will be installed
    ---> Package libXtst.x86_64 0:1.2.2-2.1.el7 will be installed
    ---> Package libpng.x86_64 2:1.5.13-7.el7_2 will be installed
    ---> Package xorg-x11-fonts-Type1.noarch 0:7.5-9.el7 will be installed
    --> Processing Dependency: ttmkfdir for package: xorg-x11-fonts-Type1-7.5-9.el7.noarch
    --> Processing Dependency: ttmkfdir for package: xorg-x11-fonts-Type1-7.5-9.el7.noarch
    --> Processing Dependency: mkfontdir for package: xorg-x11-fonts-Type1-7.5-9.el7.noarch
    --> Processing Dependency: mkfontdir for package: xorg-x11-fonts-Type1-7.5-9.el7.noarch
    --> Running transaction check
    ---> Package fontpackages-filesystem.noarch 0:1.44-8.el7 will be installed
    ---> Package javapackages-tools.noarch 0:3.4.1-11.el7 will be installed
    --> Processing Dependency: python-javapackages = 3.4.1-11.el7 for package: javapackages-tools-3.4.1-11.el7.noarch
    --> Processing Dependency: libxslt for package: javapackages-tools-3.4.1-11.el7.noarch
    ---> Package libICE.x86_64 0:1.0.9-2.el7 will be installed
    ---> Package libSM.x86_64 0:1.2.2-2.el7 will be installed
    ---> Package libX11-common.noarch 0:1.6.3-2.el7 will be installed
    ---> Package libxcb.x86_64 0:1.11-4.el7 will be installed
    --> Processing Dependency: libXau.so.6()(64bit) for package: libxcb-1.11-4.el7.x86_64
    ---> Package lksctp-tools.x86_64 0:1.0.13-3.el7 will be installed
    ---> Package ttmkfdir.x86_64 0:3.0.9-42.el7 will be installed
    ---> Package tzdata-java.noarch 0:2016f-1.el7 will be installed
    ---> Package xorg-x11-font-utils.x86_64 1:7.5-20.el7 will be installed
    --> Processing Dependency: libfontenc.so.1()(64bit) for package: 1:xorg-x11-font-utils-7.5-20.el7.x86_64
    --> Processing Dependency: libXfont.so.1()(64bit) for package: 1:xorg-x11-font-utils-7.5-20.el7.x86_64
    --> Running transaction check
    ---> Package libXau.x86_64 0:1.0.8-2.1.el7 will be installed
    ---> Package libXfont.x86_64 0:1.5.1-2.el7 will be installed
    ---> Package libfontenc.x86_64 0:1.1.2-3.el7 will be installed
    ---> Package libxslt.x86_64 0:1.1.28-5.el7 will be installed
    ---> Package python-javapackages.noarch 0:3.4.1-11.el7 will be installed
    --> Processing Dependency: python-lxml for package: python-javapackages-3.4.1-11.el7.noarch
    --> Running transaction check
    ---> Package python-lxml.x86_64 0:3.2.1-4.el7 will be installed
    --> Finished Dependency Resolution
     
    Dependencies Resolved
     
    ================================================================================
     Package                      Arch    Version                    Repository
                                                                            Size
    ================================================================================
    Installing:
     java-1.8.0-openjdk           x86_64  1:1.8.0.101-3.b13.el7_2    updates  221 k
    Installing for dependencies:
     alsa-lib                     x86_64  1.0.28-2.el7               base     391 k
     fontconfig                   x86_64  2.10.95-7.el7              base     228 k
     fontpackages-filesystem      noarch  1.44-8.el7                 base     9.9 k
     giflib                       x86_64  4.1.6-9.el7                base      40 k
     java-1.8.0-openjdk-headless  x86_64  1:1.8.0.101-3.b13.el7_2    updates   31 M
     javapackages-tools           noarch  3.4.1-11.el7               base      73 k
     libICE                       x86_64  1.0.9-2.el7                base      65 k
     libSM                        x86_64  1.2.2-2.el7                base      39 k
     libX11                       x86_64  1.6.3-2.el7                base     605 k
     libX11-common                noarch  1.6.3-2.el7                base     162 k
     libXau                       x86_64  1.0.8-2.1.el7              base      29 k
     libXext                      x86_64  1.3.3-3.el7                base      39 k
     libXfont                     x86_64  1.5.1-2.el7                base     150 k
     libXi                        x86_64  1.7.4-2.el7                base      40 k
     libXrender                   x86_64  0.9.8-2.1.el7              base      25 k
     libXtst                      x86_64  1.2.2-2.1.el7              base      20 k
     libfontenc                   x86_64  1.1.2-3.el7                base      30 k
     libpng                       x86_64  2:1.5.13-7.el7_2           updates  213 k
     libxcb                       x86_64  1.11-4.el7                 base     189 k
     libxslt                      x86_64  1.1.28-5.el7               base     242 k
     lksctp-tools                 x86_64  1.0.13-3.el7               base      87 k
     python-javapackages          noarch  3.4.1-11.el7               base      31 k
     python-lxml                  x86_64  3.2.1-4.el7                base     758 k
     ttmkfdir                     x86_64  3.0.9-42.el7               base      48 k
     tzdata-java                  noarch  2016f-1.el7                updates  179 k
     xorg-x11-font-utils          x86_64  1:7.5-20.el7               base      87 k
     xorg-x11-fonts-Type1         noarch  7.5-9.el7                  base     521 k
     
    Transaction Summary
    ================================================================================
    Install  1 Package (+27 Dependent packages)
     
    Total download size: 36 M
    Installed size: 114 M
    Downloading packages:
    (1/28): fontconfig-2.10.95-7.el7.x86_64.rpm                | 228 kB   00:01
    (2/28): fontpackages-filesystem-1.44-8.el7.noarch.rpm      | 9.9 kB   00:00
    (3/28): alsa-lib-1.0.28-2.el7.x86_64.rpm                   | 391 kB   00:01
    (4/28): giflib-4.1.6-9.el7.x86_64.rpm                      |  40 kB   00:00
    (5/28): libICE-1.0.9-2.el7.x86_64.rpm                      |  65 kB   00:00
    (6/28): libX11-1.6.3-2.el7.x86_64.rpm                      | 605 kB   00:00
    (7/28): java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64.rp | 221 kB   00:00
    (8/28): libX11-common-1.6.3-2.el7.noarch.rpm               | 162 kB   00:00
    (9/28): javapackages-tools-3.4.1-11.el7.noarch.rpm         |  73 kB   00:00
    (10/28): libXext-1.3.3-3.el7.x86_64.rpm                    |  39 kB   00:00
    (11/28): libXi-1.7.4-2.el7.x86_64.rpm                      |  40 kB   00:00
    (12/28): libXau-1.0.8-2.1.el7.x86_64.rpm                   |  29 kB   00:00
    (13/28): libXrender-0.9.8-2.1.el7.x86_64.rpm               |  25 kB   00:00
    (14/28): libfontenc-1.1.2-3.el7.x86_64.rpm                 |  30 kB   00:00
    (15/28): libSM-1.2.2-2.el7.x86_64.rpm                      |  39 kB   00:00
    (16/28): libXtst-1.2.2-2.1.el7.x86_64.rpm                  |  20 kB   00:00
    (17/28): libxcb-1.11-4.el7.x86_64.rpm                      | 189 kB   00:00
    (18/28): lksctp-tools-1.0.13-3.el7.x86_64.rpm              |  87 kB   00:00
    (19/28): libXfont-1.5.1-2.el7.x86_64.rpm                   | 150 kB   00:00
    (20/28): python-javapackages-3.4.1-11.el7.noarch.rpm       |  31 kB   00:00
    (21/28): python-lxml-3.2.1-4.el7.x86_64.rpm                | 758 kB   00:00
    (22/28): ttmkfdir-3.0.9-42.el7.x86_64.rpm                  |  48 kB   00:00
    (23/28): libpng-1.5.13-7.el7_2.x86_64.rpm                  | 213 kB   00:00
    (24/28): xorg-x11-font-utils-7.5-20.el7.x86_64.rpm         |  87 kB   00:00
    (25/28): xorg-x11-fonts-Type1-7.5-9.el7.noarch.rpm         | 521 kB   00:00
    (26/28): libxslt-1.1.28-5.el7.x86_64.rpm                   | 242 kB   00:00
    (27/28): tzdata-java-2016f-1.el7.noarch.rpm                | 179 kB   00:00
    (28/28): java-1.8.0-openjdk-headless-1.8.0.101-3.b13.el7_2 |  31 MB   00:02
    --------------------------------------------------------------------------------
    Total                                              9.0 MB/s |  36 MB  00:03
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : libfontenc-1.1.2-3.el7.x86_64                               1/28
      Installing : libICE-1.0.9-2.el7.x86_64                                   2/28
      Installing : libxslt-1.1.28-5.el7.x86_64                                 3/28
      Installing : python-lxml-3.2.1-4.el7.x86_64                              4/28
      Installing : python-javapackages-3.4.1-11.el7.noarch                     5/28
      Installing : javapackages-tools-3.4.1-11.el7.noarch                      6/28
      Installing : libSM-1.2.2-2.el7.x86_64                                    7/28
      Installing : libXfont-1.5.1-2.el7.x86_64                                 8/28
      Installing : 1:xorg-x11-font-utils-7.5-20.el7.x86_64                     9/28
      Installing : lksctp-tools-1.0.13-3.el7.x86_64                           10/28
      Installing : libXau-1.0.8-2.1.el7.x86_64                                11/28
      Installing : libxcb-1.11-4.el7.x86_64                                   12/28
      Installing : alsa-lib-1.0.28-2.el7.x86_64                               13/28
      Installing : libX11-common-1.6.3-2.el7.noarch                           14/28
      Installing : libX11-1.6.3-2.el7.x86_64                                  15/28
      Installing : libXext-1.3.3-3.el7.x86_64                                 16/28
      Installing : libXi-1.7.4-2.el7.x86_64                                   17/28
      Installing : libXtst-1.2.2-2.1.el7.x86_64                               18/28
      Installing : giflib-4.1.6-9.el7.x86_64                                  19/28
      Installing : libXrender-0.9.8-2.1.el7.x86_64                            20/28
      Installing : ttmkfdir-3.0.9-42.el7.x86_64                               21/28
      Installing : fontpackages-filesystem-1.44-8.el7.noarch                  22/28
      Installing : fontconfig-2.10.95-7.el7.x86_64                            23/28
      Installing : xorg-x11-fonts-Type1-7.5-9.el7.noarch                      24/28
      Installing : 2:libpng-1.5.13-7.el7_2.x86_64                             25/28
      Installing : tzdata-java-2016f-1.el7.noarch                             26/28
      Installing : 1:java-1.8.0-openjdk-headless-1.8.0.101-3.b13.el7_2.x86_   27/28
      Installing : 1:java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64          28/28
      Verifying  : libXext-1.3.3-3.el7.x86_64                                  1/28
      Verifying  : tzdata-java-2016f-1.el7.noarch                              2/28
      Verifying  : giflib-4.1.6-9.el7.x86_64                                   3/28
      Verifying  : libXtst-1.2.2-2.1.el7.x86_64                                4/28
      Verifying  : 1:java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64           5/28
      Verifying  : python-lxml-3.2.1-4.el7.x86_64                              6/28
      Verifying  : libxcb-1.11-4.el7.x86_64                                    7/28
      Verifying  : 2:libpng-1.5.13-7.el7_2.x86_64                              8/28
      Verifying  : fontpackages-filesystem-1.44-8.el7.noarch                   9/28
      Verifying  : ttmkfdir-3.0.9-42.el7.x86_64                               10/28
      Verifying  : libX11-1.6.3-2.el7.x86_64                                  11/28
      Verifying  : python-javapackages-3.4.1-11.el7.noarch                    12/28
      Verifying  : 1:java-1.8.0-openjdk-headless-1.8.0.101-3.b13.el7_2.x86_   13/28
      Verifying  : libXrender-0.9.8-2.1.el7.x86_64                            14/28
      Verifying  : libX11-common-1.6.3-2.el7.noarch                           15/28
      Verifying  : xorg-x11-fonts-Type1-7.5-9.el7.noarch                      16/28
      Verifying  : libxslt-1.1.28-5.el7.x86_64                                17/28
      Verifying  : libXfont-1.5.1-2.el7.x86_64                                18/28
      Verifying  : libICE-1.0.9-2.el7.x86_64                                  19/28
      Verifying  : javapackages-tools-3.4.1-11.el7.noarch                     20/28
      Verifying  : alsa-lib-1.0.28-2.el7.x86_64                               21/28
      Verifying  : libXi-1.7.4-2.el7.x86_64                                   22/28
      Verifying  : libXau-1.0.8-2.1.el7.x86_64                                23/28
      Verifying  : libSM-1.2.2-2.el7.x86_64                                   24/28
      Verifying  : libfontenc-1.1.2-3.el7.x86_64                              25/28
      Verifying  : fontconfig-2.10.95-7.el7.x86_64                            26/28
      Verifying  : lksctp-tools-1.0.13-3.el7.x86_64                           27/28
      Verifying  : 1:xorg-x11-font-utils-7.5-20.el7.x86_64                    28/28
     
    Installed:
      java-1.8.0-openjdk.x86_64 1:1.8.0.101-3.b13.el7_2
     
    Dependency Installed:
      alsa-lib.x86_64 0:1.0.28-2.el7
      fontconfig.x86_64 0:2.10.95-7.el7
      fontpackages-filesystem.noarch 0:1.44-8.el7
      giflib.x86_64 0:4.1.6-9.el7
      java-1.8.0-openjdk-headless.x86_64 1:1.8.0.101-3.b13.el7_2
      javapackages-tools.noarch 0:3.4.1-11.el7
      libICE.x86_64 0:1.0.9-2.el7
      libSM.x86_64 0:1.2.2-2.el7
      libX11.x86_64 0:1.6.3-2.el7
      libX11-common.noarch 0:1.6.3-2.el7
      libXau.x86_64 0:1.0.8-2.1.el7
      libXext.x86_64 0:1.3.3-3.el7
      libXfont.x86_64 0:1.5.1-2.el7
      libXi.x86_64 0:1.7.4-2.el7
      libXrender.x86_64 0:0.9.8-2.1.el7
      libXtst.x86_64 0:1.2.2-2.1.el7
      libfontenc.x86_64 0:1.1.2-3.el7
      libpng.x86_64 2:1.5.13-7.el7_2
      libxcb.x86_64 0:1.11-4.el7
      libxslt.x86_64 0:1.1.28-5.el7
      lksctp-tools.x86_64 0:1.0.13-3.el7
      python-javapackages.noarch 0:3.4.1-11.el7
      python-lxml.x86_64 0:3.2.1-4.el7
      ttmkfdir.x86_64 0:3.0.9-42.el7
      tzdata-java.noarch 0:2016f-1.el7
      xorg-x11-font-utils.x86_64 1:7.5-20.el7
      xorg-x11-fonts-Type1.noarch 0:7.5-9.el7
     
    Complete!
    
  11. Verify Java version installed:

    
    java -version
    
    openjdk version "1.8.0_101"
    OpenJDK Runtime Environment (build 1.8.0_101-b13)
    OpenJDK 64-Bit Server VM (build 25.101-b13, mixed mode)
    



    Install Git

  12. Per this, install from command line:

    sudo yum install git

    the response:

    Failed to set locale, defaulting to C
    Loaded plugins: fastestmirror
    base                                                     | 3.6 kB     00:00     
    docker-main-repo                                         | 2.9 kB     00:00     
    extras                                                   | 3.4 kB     00:00     
    jenkins                                                  | 2.9 kB     00:00     
    updates                                                  | 3.4 kB     00:00     
    (1/3): jenkins/primary_db                                  |  85 kB   00:00     
    (2/3): docker-main-repo/primary_db                         |  19 kB   00:01     
    (3/3): updates/7/x86_64/primary_db                         | 6.4 MB   00:01     
    Determining fastest mirrors
            * base: ftp.osuosl.org
            * extras: mirrors.sonic.net
            * updates: mirrors.evowise.com
    Resolving Dependencies
    --> Running transaction check
    ---> Package git.x86_64 0:1.8.3.1-6.el7_2.1 will be installed
    --> Processing Dependency: perl-Git = 1.8.3.1-6.el7_2.1 for package: git-1.8.3.1-6.el7_2.1.x86_64
    --> Processing Dependency: perl(Term::ReadKey) for package: git-1.8.3.1-6.el7_2.1.x86_64
    --> Processing Dependency: perl(Git) for package: git-1.8.3.1-6.el7_2.1.x86_64
    --> Processing Dependency: perl(Error) for package: git-1.8.3.1-6.el7_2.1.x86_64
    --> Processing Dependency: libgnome-keyring.so.0()(64bit) for package: git-1.8.3.1-6.el7_2.1.x86_64
    --> Running transaction check
    ---> Package libgnome-keyring.x86_64 0:3.8.0-3.el7 will be installed
    ---> Package perl-Error.noarch 1:0.17020-2.el7 will be installed
    ---> Package perl-Git.noarch 0:1.8.3.1-6.el7_2.1 will be installed
    ---> Package perl-TermReadKey.x86_64 0:2.30-20.el7 will be installed
    --> Finished Dependency Resolution
     
    Dependencies Resolved
     
    ================================================================================
     Package               Arch        Version                   Repository    Size
    ================================================================================
    Installing:
     git                   x86_64      1.8.3.1-6.el7_2.1         updates      4.4 M
    Installing for dependencies:
     libgnome-keyring      x86_64      3.8.0-3.el7               base         109 k
     perl-Error            noarch      1:0.17020-2.el7           base          32 k
     perl-Git              noarch      1.8.3.1-6.el7_2.1         updates       53 k
     perl-TermReadKey      x86_64      2.30-20.el7               base          31 k
     
    Transaction Summary
    ================================================================================
    Install  1 Package (+4 Dependent packages)
     
    Total download size: 4.6 M
    Installed size: 23 M
    Is this ok [y/d/N]: _
    
  13. Press “y” to continue.

    The response:

    Downloading packages:
    (1/5): libgnome-keyring-3.8.0-3.el7.x86_64.rpm             | 109 kB   00:00     
    (2/5): perl-Error-0.17020-2.el7.noarch.rpm                 |  32 kB   00:00     
    (3/5): perl-TermReadKey-2.30-20.el7.x86_64.rpm             |  31 kB   00:00     
    (4/5): perl-Git-1.8.3.1-6.el7_2.1.noarch.rpm               |  53 kB   00:00     
    (5/5): git-1.8.3.1-6.el7_2.1.x86_64.rpm                    | 4.4 MB   00:01     
    --------------------------------------------------------------------------------
    Total                                              4.1 MB/s | 4.6 MB  00:01     
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : 1:perl-Error-0.17020-2.el7.noarch                            1/5 
      Installing : libgnome-keyring-3.8.0-3.el7.x86_64                          2/5 
      Installing : perl-TermReadKey-2.30-20.el7.x86_64                          3/5 
      Installing : git-1.8.3.1-6.el7_2.1.x86_64                                 4/5 
      Installing : perl-Git-1.8.3.1-6.el7_2.1.noarch                            5/5 
      Verifying  : perl-Git-1.8.3.1-6.el7_2.1.noarch                            1/5 
      Verifying  : perl-TermReadKey-2.30-20.el7.x86_64                          2/5 
      Verifying  : libgnome-keyring-3.8.0-3.el7.x86_64                          3/5 
      Verifying  : 1:perl-Error-0.17020-2.el7.noarch                            4/5 
      Verifying  : git-1.8.3.1-6.el7_2.1.x86_64                                 5/5 
    
    

Installed: git.x86_64 0:1.8.3.1-6.el7_2.1
  Dependency Installed: libgnome-keyring.x86_64 0:3.8.0-3.el7 perl-Error.noarch 1:0.17020-2.el7
perl-Git.noarch 0:1.8.3.1-6.el7_2.1 perl-TermReadKey.x86_64 0:2.30-20.el7   Complete! </pre>

  1. Verify version installed:

    git –version

    The response:

    git version 1.8.3.1
    
  2. List the location installed:

    type git

    The response:

    /usr/bin/git
    
  3. Try the command with no parameters:

    git

    The response:

    usage: git [--version] [--help] [-c name=value]
            [--exec-path[=]] [--html-path] [--man-path] [--info-path]
            [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
            [--git-dir=] [--work-tree=] [--namespace=]
             []
     
    The most commonly used git commands are:
    add        Add file contents to the index
    bisect     Find by binary search the change that introduced a bug
    branch     List, create, or delete branches
    checkout   Checkout a branch or paths to the working tree
    clone      Clone a repository into a new directory
    commit     Record changes to the repository
    diff       Show changes between commits, commit and working tree, etc
    fetch      Download objects and refs from another repository
    grep       Print lines matching a pattern
    init       Create an empty Git repository or reinitialize an existing one
    log        Show commit logs
    merge      Join two or more development histories together
    mv         Move or rename a file, a directory, or a symlink
    pull       Fetch from and merge with another repository or a local branch
    push       Update remote refs along with associated objects
    rebase     Forward-port local commits to the updated upstream head
    reset      Reset current HEAD to the specified state
    rm         Remove files from the working tree and from the index
    show       Show various types of objects
    status     Show the working tree status
    tag        Create, list, delete or verify a tag object signed with GPG
     
    'git help -a' and 'git help -g' lists available subcommands and some
    concept guides. See 'git help ' or 'git help <concept>'
    to read about a specific subcommand or concept.
    </pre>
    
    ### Install Jenkins2 #
    
    
  4. Download Jenkins from the Red Hat repo:

    sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo

    QUESTION: What version of Jenkins?

    /pkg.jenkins-ci.org/redhat/jenkins.repo
    --2016-07-27 19:26:57--  http://pkg.jenkins-ci.org/redhat/jenkins.repo
    Resolving pkg.jenkins-ci.org (pkg.jenkins-ci.org)... 52.202.51.185
    Connecting to pkg.jenkins-ci.org (pkg.jenkins-ci.org)|52.202.51.185|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 71
    Saving to: '/etc/yum.repos.d/jenkins.repo'
     
    100%[======================================>] 71          --.-K/s   in 0s
     
    2016-07-27 19:26:57 (8.20 MB/s) - '/etc/yum.repos.d/jenkins.repo' saved [71/71]
    

    NOTE: The wget tool downloads files into the filename specified after the “O” flag (that’s a capital ‘O’, not a zero).

  5. Import the verification key using the package manager RPM:

    
    sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
    

    There is no response if successful.

  6. Install Jenkins by running:

    sudo yum install jenkins

    The response:

    Failed to set locale, defaulting to C
    Loaded plugins: fastestmirror
    jenkins                                                  | 2.9 kB     00:00
    jenkins/primary_db                                         |  85 kB   00:00
    Loading mirror speeds from cached hostfile
            * base: mirror.n5tech.com
            * extras: mirror.pac-12.org
            * updates: mirror.math.princeton.edu
    Resolving Dependencies
    --> Running transaction check
    ---> Package jenkins.noarch 0:2.15-1.1 will be installed
    --> Finished Dependency Resolution
     
    Dependencies Resolved
     
    ================================================================================
     Package           Arch             Version             Repository         Size
    ================================================================================
    Installing:
     jenkins           noarch           2.15-1.1            jenkins            65 M
     
    Transaction Summary
    ================================================================================
    Install  1 Package
     
    Total download size: 65 M
    Installed size: 66 M
    Is this ok [y/d/N]:
    
  7. Type y.

    The response:

    Downloading packages:
    jenkins-2.15-1.1.noarch.rpm                                |  65 MB   00:07
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : jenkins-2.15-1.1.noarch                                      1/1
      Verifying  : jenkins-2.15-1.1.noarch                                      1/1
     
    Installed:
      jenkins.noarch 0:2.15-1.1
     
    Complete!
    

    Start Jenkins

  8. Start Jenkins as a service:

    sudo systemctl start jenkins.service

    There is no response if successful.

  9. List the process being used by Jenkins with a Linux command:

    ps aux | less

    Optional: http://www.cyberciti.biz/faq/show-all-running-processes-in-linux/

  10. Check the status of the service:

    sudo systemctl status jenkins.service

    If everything went well, you should see two lines similar to the following:

    ● jenkins.service - LSB: Jenkins Continuous Integration Server
    Loaded: loaded (/etc/rc.d/init.d/jenkins)
    Active: active (running) since Wed 2016-07-27 19:31:35 UTC; 1min 54s ago
      Docs: man:systemd-sysv-generator(8)
      Process: 2272 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS)
    CGroup: /system.slice/jenkins.service
            └─2287 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -D...
     
    Jul 27 19:31:34 centos-512mb-sfo2-01 systemd[1]: Starting LSB: Jenkins Conti....
    Jul 27 19:31:34 centos-512mb-sfo2-01 runuser[2273]: pam_unix(runuser:session)...
    Jul 27 19:31:35 centos-512mb-sfo2-01 jenkins[2272]: Starting Jenkins [  OK  ]
    Jul 27 19:31:35 centos-512mb-sfo2-01 systemd[1]: Started LSB: Jenkins Contin....
    Hint: Some lines were ellipsized, use -l to show in full.
     
    Loaded: loaded (/etc/systemd/system/jenkins.service; disabled)
    Active: active (running) since Tue 2015-12-29 00:00:16 EST; 17s ago
    

    “Active: active (running)” means the Jenkins services completed its startup and is running.

    If you see:
    “Active: Active (exited)” stop and start the service again, as described below.

  11. Visit the address using an internet browser. For example:

    
    http://138.68.1.138:8080
    

    NOTE: It may take several minutes for the server to come up.

  12. Click here to Skip pass other installation options to Unlock Jenkins Admin Password

    Stop Jenkins

  13. Stop the Jenkins server:

    sudo systemctl stop jenkins.service

  14. Check status of the service again:

    sudo systemctl status jenkins.service

    You should see:

    "Active: inactive (dead)"
    

Update current version of Jenkins

Update current Version of Jenkins through repo on Digital Ocean SaaS using Putty for Windows.

  1. Connect to the Digital Ocean server via Putty.
  2. Provide username and password.
  3. Follow the below commands.
# Download Jenkins from the Red Hat repo:
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
# Import the verification key using the package manager RPM:
sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
# Install Jenkins by running:
sudo yum install jenkins
# Input Y
# Start Jenkins as a service:
sudo systemctl start jenkins.service
# Check the status of the service:
sudo systemctl status jenkins.service
# Open browser to http://138.68.1.138:8080

### GitHub Token #

  1. Login to the GitHub account to be referenced from within Jenkins.

  2. Select Settings.

  3. Click “Personl access tokens”.

  4. Click “Generate new token”.

  5. For Token Description, enter “jenkins”.

  6. Check “repo” and “adminrepo_hook” and all under them.

  7. Click “Generate token”.

  8. Copy the token content to your clipboard.

    GitHub Authenticate

  9. Go to Jenkins server, Manage Jenkins, Global Toll Configuration.

  10. In Git, add Name “Git”, Path: “git” (doesn’t matter). Click Save.

  11. Go to Jenkins server, Manage Jenkins, Configure System.

  12. In GitHub section, API URL leave “https://api.github.com”. Click Add,

  13. Select “Secret Text”.

  14. Click “Test Connection”.

AWS CodeDeploy service

Pre-requisites

Define what will be specified later:

  1. Define EC2 Key Pair.
  2. Define VPC id.
  3. Define VPC subnet.

Use Kubernetes

TBD

Use CloudFormation

  1. Go to AWS CloudFormation service, Create stack.
  2. Create a CloudFormation template based on this one.
  3. Upload it to S3.
  4. Specify a Stack name according to your organization’s naming standards. (For now we use “Jenkins1”).
  5. For Parameters, select an Instance Type (t2.micro).
  6. For YourIPRange, type “0.0.0.0” to expose it to the world. Next.
  7. Options: Tag a key not necessary.
  8. Advanced notification options and stack policy not used for now. Next.
  9. Check acknowledge resource creation (to talk to CodePipeline).
  10. Click Create in the Summary page.

    Status goest from CREATE_IN_PROGRESS to CREATE_COMPLETE.

Amazon EC2 Installation

If you have a prefer to select your own server sizes on EC2, Jenkins can be hosted on the Amazon cloud several ways.

Jeff Shantz did a great job on his videos on “Continuous Integration with Jenkins on Amazon EC2” (from 2014): 1, 2, 3, 4, 5

However, there are some updates necessary two years later.

GKC (Google Compute Engine)

To instantiate a Jenkins instance within a Docker container on the Google Kubernetes-based Compute Engine Cloud within the Google Compute Platform:

DOC

https://cloud.google.com/compute/docs/containers/deploying-containers

Google provides a Container-optimized OS.

Deploying software on VM boot using a startup script or cloud-init.
  1. Identify a containerized app within a Docker image published publicly on Docker Hub:

    https://hub.docker.com/search/?isAutomated=0&isOfficial=0&page=1&pullCount=0&q=jenkins&starCount=0

  2. Pull the official Long Term one at https://hub.docker.com/r/jenkins/jenkins/

    docker pull jenkins/jenkins:lts

    # install docker-ce RUN apt-get update RUN apt-get install -y \ apt-transport-https \ ca-certificates \ curl \ gnupg2 \ software-properties-common RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - RUN add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/debian \ $(lsb_release -cs) \ stable" RUN apt-get update RUN apt-get install -y docker-ce 
    
  3. Mount your docker socket as a volume inside the container -

    /var/run/docker.sock:/var/run/docker.sock:ro

Linux Installation

Alternately, to install on RedHat and Centos Linux machines:
https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Red+Hat+distributions

Local MacOS OSX Install

PROTIP: Install Jenkins locally for experimentation.

  1. Install on Mac OSX using Homebrew:

 brew update
 brew doctor
 brew install jenkins
 

A sample response:

==> Downloading http://mirrors.jenkins-ci.org/war/2.5/jenkins.war
==> Downloading from http://ftp-chi.osuosl.org/pub/jenkins/war/2.5/jenkins.war
######################################################################## 100.0%
==> jar xvf jenkins.war
==> Caveats
Note: When using launchctl the port will be 8080.

To have launchd start jenkins now and restart at login:
brew services start jenkins
Or, if you don't want/need a background service you can just run:
jenkins
==> Summary
🍺  /usr/local/Cellar/jenkins/2.5: 6 files, 66.4M, built in 2 minutes 46 seconds

Homebrew puts the jenkins.war file in:

   /usr/local/Cellar/jenkins/2.5/libexec/jenkins.war

For more information:

* http://iosfactory.blogspot.com/2015/02/jenkins-setup-for-ios-development.html

Windows Chocolatey Installation

  1. Open a Command Window.
  2. Install the Chocolatey package manager (if you haven’t already) by copying and pasting the PowerShell command from Chocolatey.org
  3. Install the version of Jenkins that Chocolatey makes available:

    
    choco install jenkins
    

    If Java is not installed on your computer already, it will be installed as a dependency.

    A sample response:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Mainali>choco install jenkins
Chocolatey detected you are not running from an elevated command shell
  (cmd/powershell). You may experience errors - many functions/packages
  require admin rights. Only advanced users should run choco w/out an
  elevated shell (and very advanced users as non-admin). When you open
  the command shell, you should ensure "Run as Administrator".
Chocolatey (v0.9.8.31) is installing 'jenkins' and dependencies. By installing y
ou accept the license for 'jenkins' and each dependency you are installing.

jenkins v1.645.0.0

Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d----        01/24/2016     23:09            jenkins

Downloading jenkins 64 bit
  from 'http://mirrors.jenkins-ci.org/windows/jenkins-1.645.zip'
Extracting C:\Users\Mainali\AppData\Local\Temp\chocolatey\jenkins\jenkins-1.645.
zip to C:\Users\Mainali\AppData\Local\Temp\chocolatey\jenkins...
C:\Users\Mainali\AppData\Local\Temp\chocolatey\jenkins
Installing jenkins...
jenkins has been installed.
Finished installing 'jenkins' and dependencies - if errors not shown in console,
 none detected. Check log for errors if unsure.

Notice Java is installed on path C:\Users\%User%\AppData\Local\Temp\chocolatey\jenkins, where %user% is what’s on your own computer.

Windows Installation from download

CAUTION: Do not download the Windows jenkins.msi such as:

https://jenkins.io/content/thank-you-downloading-windows-installer

After you install to Program Files(x86). Install 2.7.1. Finish.

A web server is automatically created on localhost:8080 and pops up an Authorization.

But what is the User Name and Password?

So here is the approach that Umesh Lakana recommends:

  1. Download the jenkins.war file from

    http://ftp.tsukuba.wide.ad.jp/software/jenkins/war-stable/2.7.1/jenkins.war

Ansible

See https://blog.nimbleci.com/2016/10/11/how-to-deploy-jenkins-completely-pre-configured/


Verify Installation

Regardless of the installation mechanism:

  1. Verify intallation on a Mac or Linux:

    which jenkins
    

    The response is the location Jenkins was installed:

    /usr/local/bin/jenkins
    

Manage server

Start, stop, and kill the server.

Start server with defaults

The command to start Jenkins has several parameters.

  1. See https://wiki.jenkins-ci.org/display/JENKINS/Starting+and+Accessing+Jenkins for a full explanation, inclidiong use of nohup.

  2. Start Jenkins using defaults:

    jenkins
    

    If all goes well, you should see:

    INFO: Jenkins is fully up and running.
    
  3. Confirm tcp ports Jenkins uses as java (8005 sharing, 8009, 8080):

    netstat | grep java
    

    NOTE: This command takes a minute or more.

    Stop server

    PROTIP: Do not stop the Jenkins instance by clicking the red X to close the command window Jenkins runs under. Doing a soft-stop enables Jenkins to save data to memory rather than potentially lose data during a hard and sudden stop.

  4. Stop the server by escaping the process.

    • Ctrl+C on Windows
    • command+C on Macs

     

    The response is:

    INFO: JVM is terminating. Shutting down Winstone
    

    Server process status

    Use the process status command to find the process ID to kill:

    ps -eaf | grep jenkins

    A sample response:

  501  4137     1   0 Thu06AM ??         2:54.41 /usr/bin/java -Dmail.smtp.starttls.enable=true -jar /usr/local/opt/jenkins/libexec/jenkins.war --httpListenAddress=127.0.0.1 --httpPort=8080
  501 14728 14384   0  6:31PM ttys002    0:00.00 grep jenkins
  1. To remove the Jenkins process, highlight the process number associated with java and copy it to your Clipboard, then paste it in this command:

    
     kill 4137
     

First-time setup

Use HTTPS

PROTIP: Encrypt over the wire by using https instead of https.

  1. Start Jenkins again using more parameters:

    
    java -jar jenkins.war --httpPort=-1 --httpsPort=8081 –httpListenAddress=0.0.0.0
    

    Value -1 turns off the port.

    –httpListenAddress=0.0.0.0 allows remote access, while 127.0.0.1 does not.

    A sample response:

   Running from: /usr/local/Cellar/jenkins/2.5/libexec/jenkins.war
   webroot: $user.home/.jenkins
   Jan 26, 2016 8:52:21 AM winstone.Logger logInternal
   INFO: Beginning extraction from war file
   Jan 26, 2016 8:52:21 AM org.eclipse.jetty.util.log.JavaUtilLog info
   INFO: jetty-winstone-2.9
   Jan 26, 2016 8:52:27 AM org.eclipse.jetty.util.log.JavaUtilLog info
   INFO: NO JSP Support for , did not find org.apache.jasper.servlet.JspServlet
   Jenkins home directory: /Users/wmar/.jenkins found at: $user.home/.jenkins
   Jan 26, 2016 8:52:34 AM org.eclipse.jetty.util.log.JavaUtilLog info
   INFO: Started SelectChannelConnector@0.0.0.0:8081
   Jan 26, 2016 8:52:34 AM winstone.Logger logInternal
   INFO: Winstone Servlet Engine v2.0 running: controlPort=disabled
   

NOTE: Some use a domain name to reach the IP address.

Obtain the password

On a Mac machine, copy this path and change $USER to your user name:


   /User/$USER/.jenkins/secrets/initialAdminPassword
   

On a Linux machine, copy this path:


   /var/lib/jenkins/secrets/initialAdminPassword
   
  1. Open a new Terminal session.
  2. Type the contents using the cat command:

    cat /var/lib/jenkins/secrets/initialAdminPassword
    

    A sample response:

    f79db609207e4d06ba2344a0d4d66cf9
    
  3. Copy the password revealed and dismiss the editor window.

Establish Jenkins

On the Jenkins screen UI:

Unlock Jenkins Admin password

  1. Click in the Administrator password field and press Ctrl+V to paste the password from your Clipboard.

  2. Click Continue.

    CAUTION: Close the window showing the log would shut down Jenkins.

  3. Return to the web page and paste it under “Administrator password”.

  4. Press Continue.

    Customize Initial Plug-ins

    PROTIP: DO NOT click “Install the Suggested Plugins” Recommended.

    PROTIP: Configure one plug-in at a time. This makes it easier to troubleshoot.

  5. Click Select plugins to install.

    NOTE: Click the Suggested link at the top of the screen to reset selections.

  6. Uncheck and check these plugins based on my analysis of Jenkins plugins:

    [X] Folders Plugin

    [_] OWASP Markup Formatter Plugin

    [X] build time-out plugin

    [X] Credentials Binding Plugin

    [X] Timestamper

    [X] Workspace Cleanup Plugin

    [X] Ant Plugin

    [X] Gradle Plugin

    [+] Nodejs Plugin

    [X] Pipeline

    [X] GitHub Organization Folder Plugin

    [X] Pipeline: Stage View Plugin

    [x] Git Plugin

    [+] GitHub Plugin

    [_] Subversion Plugin

    [+] Matrix Project Plugin

    [_] SSH Slaves Plugin

    [_] Matrix Authorization Strategy Plugin

    [_] PAM Authentication Plugin

    [_] LDAP Plugin

    [X] Email Extension plugin

    [X] Mailer plugin

    TROUBLESHOOTING: This error appears if Jenkins timed out: “An error occurred during installation: No valid crumb was included in the request”. Jenkins restarts on its own.

  7. Click Install.

    The “Getting Started” page shows the progress of plug-ins being installed.

    Create First Admin User

    Back to the Jenkins web page UI after plug-ins are installed:

  8. PROTIP: Open a text file and type your choice for Username, Password, Confirm, Full Name, E-mail address. Do this in case there is a typo.

  9. Copy each answer from the file and paste it on the screen.

    PROTIP: Print the file and store it in a safe place but where other administrators know to access.

  10. Press OK (or “Start Using Jenkins” in older versions) to see the login screen:

  11. Type in the credentials entered earlier.

Dashboard Explained

  1. The whole page is called a Dashboard.
  2. Breadcrumbs show the hierarchy of page navigation.
  3. Menu items are within a Sidebar.
  4. Under the Build Queue heading.
  5. Under the Build Executor Status heading.
  6. To the right of the All view ???
  7. Under the Name column are jobs and projects.
  8. Build.
  9. Different colors of icons under the S column indicate differing build status.
  10. Different colors of icons under the W column indicate differing uild trend, where yellow sunshine is good and a thundercloud is bad.

Configure User Security

Jenkins installation options are described at:

  • https://wiki.jenkins-ci.org/display/JENKINS/Starting+and+Accessing+Jenkins

By default, Jenkins stores its configuration files in the user’s home folder at ~/.jenkins.

To make a Jenkins server completely public (and open to hacking) use a text editor to edit ~jenkins/.ssh/config to add StrictHostKeyChecking no.

  1. Create a key without a passphrase, per https://help.github.com/articles/generating-ssh-keys/

  2. Login under user named Jenkins (if applicable):

    sudo su jenkins
    
  3. Copy your github key to Jenkins .ssh folder.

    cp ~/.ssh/id_rsa_github*  /var/lib/jenkins/.ssh/
    
  4. Raname the keys:

    mv id_rsa_github id_rsa
    mv id_rsa_github.pub id_rsa.pub
    

Add User Permissions

  1. Bring up Jenkins in your default browser:

    https://localhost:8081/

    If you don’t see the full menu (shown on the right), you don’t have some permissions.

    As with other systems, granting permissions is typically done only by the Administrator of the system.

  2. Click Manage Jenkins on the left menu of the Dashboard screen.

    do_jenkins_createuser_globalsecurity_02

  3. Click Configure Global Security.

  4. Check the option box for Enable Security.
  5. If you have an LDAP, select that.

    do_jenkins_createuser_jenkensdatabase_02a

  6. Under the Access Control section, Check Use Jenkin’s own user database. But you’ll have to add each user.

    do_jenkins_createuser_globalsecurity_allowusertosignup_03

  7. Deselect the checkbox marked Allow users to sign up.

    do_jenkins_createuser_globalsecurity_auth_matrixbasedsecurity_04

  8. Under Authorization, Check Matrix-based security.

    do_jenkins_createuser_icon_08

    user

  9. Click on the small button to the right of the Anonymous row to select all permissions.

    PROTIP: Rather than specifying individual users and their permissions, the preferred approach is to first assign individual users to a group in LDAP, then assign permission to the group (like what the Windows OS does).

    do_jenkins_createuser_save_09

  10. Click on Save.

  11. To create a new user, manually create additional new users by Returning to Home and Click on Manage Jenkins.

    manageuser

  12. Scroll down and click on Manage Users.

    do_createuser

  13. From the menu on the left, Click on Create User.

    do_createuser1

  14. Fill out the Username,Password,Confirm password, Full name and E-mail address and Click on Create User

    do_usergroup

    do_userandy

  15. Use the User/group to add input field to specify a new user and Click Add
  16. Click on the small button to the right of the andy row to select all permissions.

    do_applysave

  17. Click Apply and Click Save.

  18. Install the “AWS CodePipeline Plugin” by following the next section below.

Plug-ins

See Install Jenkins Plug-ins

Global Tool Configuration

  1. From “Manage Jenkins”, click Global Tool Configuration.

  2. Click “install automatically”.

    This message appears in the Output Log if you did not finish:

    Unable to auto-install JDK until the license is accepted.
    
  3. Check “I agree to the Java SE Development Kit”.
  4. Click on “Please enter your username/password” and enter your Oracle credentials before returning.

Nodes for scalability

A Jenkins server can scale by adding nodes to spread build work across several servers running different operating systems.

Look at the Load Statistics UI to see whether additional nodes are necessary.

Jenkins slave nodes can be started by the master using several launch methods:

  • Launch slave agents on Unix machines via SSH
  • Launch slave agents via Java Web Start
  • Launch slave via execution of command on the Master
  • Let Jenkins control this Window slave as a Windows service
  1. Setup a node as a VirtualBox. TODO.

  2. In Configure Server, a node can be setup as a Virtualbox URL such as http://localhost:18083/.

  3. In Manage Nodes, configure a VBox host.
  4. Run the box by clicking the icon at the far right of the node listed.
  5. Launch Slave Agent to start the machine.

From a slave node

  1. From a slave command line, connect to a Jenkins master:

    java -jar slave.jar -jnlpUrl http://jenkins-master:8081/computer/Test Node/slave-agent.jnlp
    

Several executors can be running simultaneously. This number is specified within the Manage Jenkins UI.

Tool locations (such as Github) is also specified in that UI.

Nodes are described at:

  • https://wiki.jenkins-ci.org/display/JENKINS/Distributed+builds

Build Projects

Jenkins was initially created for automating the building (compilation) of java programs. But Jenkins is ALSO used for other types of work. Nevertheless, the Jenkins term “build” is another word for what operating systems call a “job” (unit of batch work).

Builds/jobs can be automatically triggered several ways:

  • after other projects
  • periodically on a schedule
  • poll a version control system for changes

Latest Info about Jenkins

Follow @jenkins_release This bot tweets Jenkins plugin releases.

Tweet to @jenkinsci about #Jenkins2

CloudBees Verified account @CloudBees

@jenkinsconf is the handle for Jenkins World, Sep 13-15 in Santa Clara, CA

@changelog New podcast every Friday! Sign up for our weekly and nightly emails. Open source moves fast. Keep up.

@kohsukekawa

Resources

References

https://github.com/bmuschko/cje-crash-course

https://www.harness.io/blog/chaos-engineering-with-jenkins

More on DevOps

This is one of a series on DevOps:

  1. DevOps_2.0
  2. ci-cd (Continuous Integration and Continuous Delivery)
  3. User Stories for DevOps
  4. Enterprise Software)

  5. Git and GitHub vs File Archival
  6. Git Commands and Statuses
  7. Git Commit, Tag, Push
  8. Git Utilities
  9. Data Security GitHub
  10. GitHub API
  11. TFS vs. GitHub

  12. Choices for DevOps Technologies
  13. Pulumi Infrastructure as Code (IaC)
  14. Java DevOps Workflow
  15. Okta for SSO & MFA

  16. AWS DevOps (CodeCommit, CodePipeline, CodeDeploy)
  17. AWS server deployment options
  18. AWS Load Balancers

  19. Cloud services comparisons (across vendors)
  20. Cloud regions (across vendors)
  21. AWS Virtual Private Cloud

  22. Azure Cloud Onramp (Subscriptions, Portal GUI, CLI)
  23. Azure Certifications
  24. Azure Cloud

  25. Azure Cloud Powershell
  26. Bash Windows using Microsoft’s WSL (Windows Subsystem for Linux)
  27. Azure KSQL (Kusto Query Language) for Azure Monitor, etc.

  28. Azure Networking
  29. Azure Storage
  30. Azure Compute
  31. Azure Monitoring

  32. Digital Ocean
  33. Cloud Foundry

  34. Packer automation to build Vagrant images
  35. Terraform multi-cloud provisioning automation
  36. Hashicorp Vault and Consul to generate and hold secrets

  37. Powershell Ecosystem
  38. Powershell on MacOS
  39. Powershell Desired System Configuration

  40. Jenkins Server Setup
  41. Jenkins Plug-ins
  42. Jenkins Freestyle jobs
  43. Jenkins2 Pipeline jobs using Groovy code in Jenkinsfile

  44. Docker (Glossary, Ecosystem, Certification)
  45. Make Makefile for Docker
  46. Docker Setup and run Bash shell script
  47. Bash coding
  48. Docker Setup
  49. Dockerize apps
  50. Docker Registry

  51. Maven on MacOSX

  52. Ansible
  53. Kubernetes Operators
  54. OPA (Open Policy Agent) in Rego language

  55. MySQL Setup

  56. Threat Modeling
  57. SonarQube & SonarSource static code scan

  58. API Management Microsoft
  59. API Management Amazon

  60. Scenarios for load
  61. Chaos Engineering