Skip to content

Files

Failed to load latest commit information.

Latest commit

 Cannot retrieve latest commit at this time.

History

History
 
 

jenkins

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Setting Up Jenkins for OpenEBS Continuous Integration(OCI)

Jenkins® is an open source automation server. With Jenkins, organizations can accelerate the software development process through automation. Jenkins manages and controls development lifecycle processes of all kinds, including build, document, test, package, stage, deployment, static analysis and many more.

The purpose of this user guide is to provide the user with instructions to set up Jenkins® on a workstation.

Continuous Integration - Step 1: Setting Up The Build Machine

How-to - Install Ansible and Jenkins

  • Download the setup-build-machine script file from the following URL::

    wget https://raw.githubusercontent.com/openebs/openebs/master/e2e/jenkins/setup-build-machine.sh
    
  • Run the script on the workstation with a user having sudo permissions.

  • This will install Jenkins and the required packages.

  • A user called 'jenkins' is created when you install Jenkins.

Continuous Integration - Step 2: Setting Up Jenkins using Web-Interface

  • The default way to access the Jenkins server is through a browser, using the URL:

    http://<jenkins-server>:8080
    
  • When you open this URL for the first time, you are provided with a path to a file in the server. /var/lib/jenkins/secrets/initialAdminPassword.

  • This file contains the password for user admin.

  • Once you log in, it redirects you to a Getting Started page. Click Install Suggested Plugins option.

  • You are now prompted to create a new admin user.

  • Create a user called openebs providing the required details requested by the Create First Admin User page and click Save and Finish.

  • A message "Jenkins is ready!" is displayed..

  • Click Start using Jenkins.

  • You are now logged in as user openebs and will be able to see your Dashboard.

Note:

By default, the pages in Jenkins do not refresh automatically. To enable it click on the *ENABLE AUTO REFRESH* link on the top right of the page.

Continuous Integration - Step 3: Installing Additional Plugins

  • On the left side of the Dashboard you have links for managing Jenkins.
  • Click Manage Jenkins->Manage Plugins.
  • On the Plugin Manager page, the following 4 tabs are displayed:
    • Updates
    • Available
    • Installed
    • Advanced
  • Click on Available and in the Filter field search and add following 3 plugins.
    • Environment Injector Plugin
    • Hudson Post build task
    • Slack Notification Plugin
  • Select Restart Jenkins when installation is complete and no jobs are running to restart Jenkins.

Configure Slack Plugin Preferences

Prerequisite:

Jenkins application for Slack must be installed and configured.
  • Click Manage Jenkins.
  • Click Configure System.
  • Scroll to Global Slack Notifier Settings.
    • Enter the slack team's team domain in Team Subdomain field.
    • Enter the token provided in the Jenkins application for Slack in Integration Token field.
    • Enter the slack channel details in Channel field.
    • Click Test Connection. The slack channel should be getting a notification from Jenkins.
    • If a notification is received then click Apply and Save.
    • The configuration for the Slack Plugin is complete.

Continuous Integration - Step 4: Creating The Jobs

  • Click on the create new jobs link in the Dashboard.
  • Provide a name for the project and select project type as Freestyle Project.
  • The Job page is divided into 6 categories:
    • General
    • Source Code Management
    • Build Triggers
    • Build Environment
    • Build
    • Post Build Actions
  • Click on the '?' symbol for each entry to get its relevant help.

How-to - Fill the General Category

  • The Project name is populated with the name provided for the job.
  • Provide a description for the job.
  • Select Github Project checkbox.
  • Provide the Project URL.

How-to - Fill the SCM Category

  • Select Git as the repository.
  • Provide Repository URL.
  • Set the Refspec for the repository.
  • For Additional Behaviors add Polling ignores commits in certain paths.
  • In the Excluded Regions sections add the files extensions.
    • /*.md
    • /*.rst
  • Click Apply. (Do this periodically to save your changes before the session times out)

How-to - Fill the Build Triggers Category

  • Select the Poll SCM checkbox.
  • Set the polling schedule for the repository.

How-to - Fill the Build Environment Category

  • Select Add timestamps to the Console Output checkbox.
  • Select Inject environment variables to the build process checkbox.
  • Provide the relative or absolute path for the .profile file along with the filename.
  • Select Inject passwords to the build as environment variables checkbox.
  • This option encrypts the environment variables, as a security measure for files getting checked in into the repository.

How-to - Fill the Build Category

Cloning OpenEBS, Installing ARA And Setting Up The Environment

  • Click Add Build Step drop-down list and select Execute Shell.

  • Enter the script below in the script editor provided.

    #!/bin/bash
    
    if [ ! -d "${JENKINS_HOME}/openebs" ]; then
    
    # Control will enter here if $DIRECTORY doesn't exist.
    cd ${JENKINS_HOME}
    git clone https://github.com/openebs/openebs.git
    
    cd ${JENKINS_HOME}/openebs/e2e/ansible/
    ansible-playbook setup-ara.yml
    ansible-playbook -e "run_ci=yes ci_mode=hyperconverged build_type=quick" setup-env.yml
    
    echo vagrant up
    vagrant up
    ansible-playbook -e "build_type=quick" ci.yml
    else
    
    cd ${JENKINS_HOME}/openebs/e2e/ansible/
    ansible-playbook -e "run_ci=yes ci_mode=hyperconverged build_type=quick" setup-env.yml
    
    echo vagrant up
    vagrant up
    ansible-playbook -e "build_type=quick" ci.yml
    fi
  • The script clones openebs repository for running Ansible Playbooks.

  • The script also sets up ARA for reporting.

  • Finally it runs the CI.yml to perform Continuous Integration of OpenEBS modules.

How-to - Fill the Post Build Actions Category

Adding Post Build Task And Slack Notifications

  • Click Add post-build action drop-down list and select Post build task plugin.

    • In the Log Text textbox enter text: vagrant up
    • Enter the script below in the script editor provided.
    #!/bin/bash
    
    cd ${JENKINS_HOME}/openebs/e2e/ansible/
    vagrant destroy -f
    
    # The below depends on the mode of deployment(dedicated/hyperconverged)
    ssh-keygen -f "/var/lib/jenkins/.ssh/known_hosts" -R 172.28.128.31
    ssh-keygen -f "/var/lib/jenkins/.ssh/known_hosts" -R 172.28.128.32
    ssh-keygen -f "/var/lib/jenkins/.ssh/known_hosts" -R 172.28.128.33
    • Select Escalate script execution status to job status.
  • Click Add post-build action drop-down list and select Post build task plugin.

    • In the Log Text textbox enter text: (failed=)(\d*[1-9]\d*)
    • Enter the below script in the provided script editor.
    #!/bin/bash
    exit 1
    • Select Escalate script execution status to job status.
  • Click Add post-build action drop-down list and select Slack Notifications plugin.

    • Select Notify Build Start.
    • Select Notify Failure.
    • Select Notify Success.
    • Select Notification message includes: and in the drop-down list select commit list with authours and titles.