Presentation is loading. Please wait.

Presentation is loading. Please wait.

Getting Started with Jenkins: A VMWorld workshop

Similar presentations


Presentation on theme: "Getting Started with Jenkins: A VMWorld workshop"— Presentation transcript:

1 Getting Started with Jenkins: A VMWorld workshop

2 Introductions Bob Webster Technical Marketing Manager VMware vCloud Eric Smalling Consulting Architect DevOps by VMware Professional Services @ericsmalling

3 About Us: VMware DevOps Consulting Services
Developer friendly. Enterprise ready. Assessment Strategy development People, process & technology transformation for Continuous delivery Configuration management Cloud operations Security & resilience optimization Our team of dedicated DevOps experts provide: Build and deliver applications sooner Fuel innovation and accelerate time to market Transform your enterprise to support high velocity, modern application development Deploy an agile future-ready datacenter where any app can thrive

4 Agenda What is Jenkins? Installing Jenkins
Lab1: A Quick Tour of Jenkins Configuring Jenkins & Plugins Lab2: CI with Jenkins Demo: vSphere Integration

5 What is Jenkins?

6 Jenkins Jenkins is a free / Open Source application that monitors the executions of repeated jobs It’s primarily used as a Continuous Integration Tool for building software. Jenkins Home Page

7 Jenkins and Hudson Too many butlers?
Before Jenkins, there was Hudson. Hudson was written by Kohsuke Kawaguchi at Sun Microsystems When Oracle bought Sun and planned for a Commercial version of Hudson, the open source community including Kohsuke Kawaguchi created Jenkins. Interest in Hudson declined dramatically and Oracle donated the source to the Eclipse Foundation in 2012 Today, Jenkins is a much more active project.

8 Installing Jenkins

9 Installing Jenkins The Jenkins Home Page
provides native package installers for many platforms. In this workshop we will cover installation for Windows and OSX. Long Term Stable (LTS) version is usually the best for most uses.

10 Windows Install as a windows service
Mac OSX Install Ensure Java is installed (run “java” at Terminal and follow prompts if it’s not installed yet) Visit the Jenkins home page Click on the Mac OSX native package installer link and download the package Double click the .pkg in the downloads folder on your Mac. Enter your admin password to permit the install. When the installer loads, accept the license and accept all defaults. When complete, access the Jenkins home page on your laptop at Visit the Jenkins home page ci.org Click on the Windows native package installer link and download the package Unzip the package Run the installer When complete, access the Jenkins home page on your laptop at Java and OS X 10.9 Mavericks or Yosemite Oracle Java 8 on Mavericks or Yosemite needs Apple's Java 1.6 to function. However, all of the symlinks in /usr/bin point to Java 1.6, so when a Jenkins tries to run via /Library/Application Support/Jenkins/jenkins-runner.sh, it launches using Java 1.6. To run under Java 8, you need to do the following:  Install Apple's Java from  Install Oracle Java 8 Edit jenkins-runner.sh:  Add the line:  export JAVA_HOME="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home" Change the last two lines to read:  echo "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java" $javaArgs -jar "$war" $args exec "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java" $javaArgs -jar "$war" $args Jenkins will now run using Java 8.  Start / Stop Service: To start/stop them manually, use the service manager from the control panel Start / Stop Daemon: sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist

11 Run via Java Command Line
Run in Docker container Visit the Jenkins home page ci.org Click on the link under “Java Web Archive (.war) Open a shell and cd to the download directory Run this command: “java –jar jenkins.war” Access the Jenkins home page on your laptop at CTRL-C will kill the process docker pull jenkins docker run jenkins_home (You’ll probably want to attach a volume for Jenkins to store its data) Mention these but not for students to do now (unless they want to) If Eric’s laptop is being used, Jenkins will be running via command line as shown here

12 Install Git Windows Visit the link http://git-scm.com/downloads
Click on the Windows download icon Click on the downloaded .exe file to run the installer. Select ‘Use Git from the Windows Command Prompt’ Accept all other defaults Mac OSX Open Terminal, type “git”. If not installed a window should prompt you to install the XCode command line tools. Click “Install”. Other options: Homebrew users: brew install git

13 Lab 1: A Quick Tour of Jenkins
Create a simple job View execution results Show how errors are reported

14 Lab 1: Quick Tour of Jenkins
Step 1: Click “create new jobs” or “New Item” Step 2: Give your job a name Select “Freestyle Project” Click “OK” Step 3: Scroll down to the “Build” section Click “Add build step” and select either “Execute shell” (Mac) or “Execute batch command” (Windows) from the drop down menu.

15 Lab 1: Quick Tour of Jenkins
Step 4: Add a script that logs lines over several seconds Click “Save” Step 5: You are presented with the project status page Click “Build Now” to run your project Note the build history will change

16 Lab 1: Quick Tour of Jenkins
Step 6: Click the “1” link to open that run’s status page This job is very basic so not much info is presented; a lot more data can be shown on this page (more on that later). Note the “Sunny” icon in the Build History panel. This indicates relative build status over the last several builds. Sunny = all passing Step 7: Click “Console Output” on the left side of the page The console output of the running job is listed NOTE: If you open this page while the job is still running, the log will be live, scrolling as more data comes in. (similar to “tail –f”) Tip: Clicking the ball or progress bar in the “Build History” panel will take you straight to the that run’s console output.

17 Lab 1: Quick Tour of Jenkins
Step 8: Navigate back to your project status page by clicking on the “Status” link Click on the “Configure” link to re-open the project’s configuration form Step 9: Scroll down to the Build -> Execute Shell (or batch command) section and add “exit 1” to the bottom of the script (same for Windows or Mac) Click Save Click Build Now

18 Lab 1: Quick Tour of Jenkins
Step 10: Notice the red icon next to the 2nd run in build history (when it completes the run) which indicates failure. Also note the “weather” icon has changed to “cloudy” because we have 50% failure rate. Step 11: Go back into the configuration page (click “Configure”) Remove the “exit 1” line you added earlier Click Save Click Build Now The 3rd run should go back to Blue/Pass state Weather is now “partly sunny” as the builds are now 66% passing.

19 Configuring Jenkins & Plugins

20 Configuring Jenkins Configure System Configure Global Security
Central place for global configuration settings Plugins can add sections if needed Allows system-wide governance of the build tools used JDK versions Ruby versions Configure Global Security Several authentication options Provides various levels of authorization granularity Extensible by plugins Secure credential store Manages credentials for external systems so that projects don’t have to invent their own schemes.

21 Jenkins Plugins Jenkins has over a thousand plugins that extend its functionality. Extensibility points within Jenkins enable anyone to create a plugin. A list of all available plugins is available on the Jenkins Plugin Page In this tutorial we will be using these plugins GitHub plugin

22 Lab 2: CI with Jenkins Setup a continuous integration project
Automatic builds and deploys to vCloud Air

23 Lab 2: Continuous Integration
In this lab you will setup a continuous integration project. Your project will automatically build and deploys an application to vCloud Air when source changes are made. Step 1: Clone (create) a local source code repository on your laptop Step 2: Setup a post-commit hook so Git will call Jenkins when code changes are made. Step 3: Create a new Jenkins Project that will build the source code Step 4: Modify the code and commit the change Step 5: Watch Jenkins checkout and deploy the new code Step 6: Test the change with a browser Lab Instructions

24 Jenkins Masters and Slaves
A normal Jenkins install acts as a master and uses its resources to run all jobs. An executor is the component the does the work. To perform a lot of parallel builds, slaves can be configured to perform work. A slave is a computer that is set up to offload build projects from the master and once setup this distribution of tasks is fairly automatic. The slave runs a slave agent, a full Jenkins install is not required. Jobs can be set to stick to a specific slave for a build or roam across slaves

25 Jenkins + vSphere Integration

26 vSphere Integration The vSphere Plugin offers two modes of integration
In-project build step level Perform vSphere operations inline with your job steps Ensure VM is running before build or test Shut down VM upon completion Reset target VMs to known good state before / after job run etc Automated slave provisioning / de-provisoning Starts VMs to act as slave instances as load requires them Shuts VMs down when no longer needed Useful for build / test spikes Specialized build platforms/OS’s/tools Resetting a slave to known good state

27 vSphere Deployment Demo
Demo prerequisites: vSphere ESXI is available and accessible by Jenkins A VM is available with Ubuntu Server and the following installed: open-vmtools Nginx /usr/share/nginx/html writable by the user Jenkins will be using. A snapshot taking in vSphere of this state

28 vSphere Deployment Demo
System configuration Install the “vSphere Plugin” and “SSH plugin” On Jenkins Configure System page, go to “Cloud” and select “vSphere Cloud” from the “Add a new cloud” dropdown menu. Enter your vSphere host, credentials and a name for this vSphere Cloud. Click “Test Connection” button to validate connectivity. Scroll up to the “SSH remote hosts” section and click the “Add” button. In the “hostname” field enter “$VSPHERE_IP”.

29 vSphere Deployment Demo
System configuration (cont.) Fill out the rest of the fields with the credentials for your VM user (ignore server connection form error) Click “Save” at bottom of page. Create a test job: Create a new “FreeStyle” job. Enable “This build is parameterized” and add a “String Parameter”. Name: TEST_STRING (put anything you want in the “Default Value”

30 vSphere Deployment Demo
Create a test job (cont.): In the “Build” section add two “vSphere Build Step”s In the first one, choose your vSphere server (using the cloud name you entered in the system configuration) and choose the “Revert to Snapshot” action. Fill out you VM name (from vSphere) and snapshot for the basic nginx install. In the second one, choos your vSphere server again and choose “Power-On/Resume VM” or it’s action. Fill out the VM name again here Add a “Execute shell on remote host using ssh” build step. Choose the SSH site you entered in the system configutation In the Command field enter: echo "$TEST_STRING" > /usr/share/nginx/html/index.html

31 vSphere Deployment Demo
Create a test job (cont.): Add a “Execute shell” build step and enter the following in it’s Command field: curl -s | grep "$TEST_STRING” Click “Save”, and the “Build with Parameters” A parameter form will appear – enter some text in it (or leave the default if you wish) and click “Build” While the build is running, open the console output and note that the vSphere log entries. Also, if your vSphere client console is available, note the “Recent Tasks” entries that coincide.

32 vSphere Deployment Demo
Create a test job (cont.): When complete, the log should show the text entered in the build parameter as being returned by the web server via the “curl” command. Additionally you could open a browser to the VM and see the same text.

33 Hints, Tips, Q&A

34 More Information Jenkins Home: Jenkins Documentation Wiki Mailing Lists IRC Bug Tracker Latest Jenkins CI builds and results (yes, Jenkins builds Jenkins) Jenkins User Conference: News about upcoming conferences Video and slides for past conferences Highly recommend session from 2014 SFO conference: Seven Habits of Highly Effective Jenkins Users by Andrew Bayer

35 More Information Jenkins related Twitter feeds Our Twitter feeds
@jenkinsci @jenkinsconf @jenkins_release @CloudBees @kohsukekawa Our Twitter feeds Bob Eric

36 Q & A


Download ppt "Getting Started with Jenkins: A VMWorld workshop"

Similar presentations


Ads by Google