Overview

Skill Level: Any Skill Level

In this tutorial, learn how to set up Jenkins in an IBM Cloud private cluster. We will also explore how to use Jenkins to automate the process of building and adding images in your cluster. For more information about Jenkins, see https://jenkins.io/.

Ingredients

An IBM Cloud private v1.2.0 cluster. See Installing IBM® Cloud private-ce.

Note: Your cluster must have access to the internet access to use the sample repository on GitHub.

Step-by-step

  1. Install Jenkins

    1. Log in to the IBM Cloud private console.
    2. From the console, select App Center.
    3. Locate the Jenkins package.
      • To install the package on Linux, select local-charts/jenkins.
      • To install the package on Linux on POWER 64-bit Little Endian (LE), select local-charts/jenkins-ppc64le.snap1
    4. Click Install Package.
    5. Click Review and Install.
    6. Click Install.This process might take a few minutes depending on how long it takes your cluster to load the Jenkins image. During the wait time, you can review pod events to see the progression of your deployment.
    7. OPTIONAL: To see the pod events, from the console, click the application name > pod name > Events tab.
       snap2  snap3
  2. Access the Jenkins UI

    1. From the console, select Workloads > Applications.
    2. Locate the default-jenkins-jenkins application.
    3. To display the application details for the default-jenkins-jenkins application, click its name.
    4. From the Expose Details section of the application details page, click access http endpoint. The Jenkins UI displays. snap2a
    5. Log in to your Jenkins UI with the default user name and password: admin:admin.snap5-1
  3. Create a Jenkins Project

    1. From the Jenkins UI, click create new jobs.
    2. From the project page, enter the project name “demo” and select Freestyle project.
    3. Click OK.

    snap6-1

  4. Configure your Jenkins project

    From the Jenkins configuration page for your demo project, update the source code management, build triggers, and build environment sections.

    Source Code Management

    1. From the Source Code Management section, select Git.  
    2. Paste the sample repository URL, https://github.com/cfc-cicd/cron-test.git. snap7-1

     

    Build Triggers

    1. From the Build Triggers section, select Poll SCM.
    2. Input a cron schedule. For example, enter H/5 * * * * to poll the Git repo for new commits every 5 minutes.snap8a-1

     

    Build Environment

     

    In this step, configure Jenkins to use the Dockerfile located in the sample Git repository to build the image cron:latest, and then push the image into the IBM Cloud private Docker registry at master.cfc:8500.

    1. Click Add build step > Docker Build and Publish.  
    2. Input the following information:
      • Repository Name : default/cron. This command places a copy of the “cron” image in the “default” repository.
      • Tag: latest
      • Docker Host URI: unix:///var/run/docker.sock
      • Server credentials: none
      • Docker registry URL: https://master.cfc:8500 snap10a
      • Set the Registry credentials

                           i. Click Add > Jenkins.

                           ii. Input the following values:

                                Username: admin

                                Password: admin

                                ID: cfc-user-password

                                Description: cfc-user-password

                                 snap9-1

                           iii.  Click Add.

                           iv.  From the registry credentials list, select admin/*******(cfc-user-password).

                                snap10b

    Click Save.

    Click Build Now.

  5. Review

    1. Review the Build History to see the progress of your build.
    2. Click the build name to view its details.snap13-2
    3. Click Console Output to see the task details.snap14-3
    4. If the build task is successful, you can find a new image – master.cfc:8500/default/cron:latest – in the IBM Cloud private cluster management console. To view the image, from the console menu bar, select Infrastructure > Images.

Join The Discussion