Wilson Mar bio photo

Wilson Mar

Hello!

Calendar YouTube Github

LinkedIn

You own Minions

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 article covers the installation and use of Jenkins plugins.

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.

The assumption here is that you have followed Jenkins Setup to install the latest version of Jenkins2, which went Version 2 April 26, 2016 after over 10 years at v1.

Find plugins to install

Here is a generic set of steps to install a plug-in:

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

  2. Click Manage Plugins to http://…/pluginManager/

  3. Click Installed tab to view what has been installed already.
  4. Click Available tab to http://…/pluginManager/available
  5. Click Advanced tab and scroll to the bottom to see the Update Site URL for the source of plugins listed:

    http://updates.jenkins-ci.org/update-center.json
    

    NOTE: You can upload a plugin file with the file extension .hpi to folder <jenkinsHome>/plugins/

    On a Mac, the jenkinshome is ~/.jenkins.

    So many plugins

  6. View the Wiki on Plugins.

    PROTIP: The wide variety of plugins is why Jenkins is popular.

    See xxx

  7. Click on a category (such as “.NET Development”) to contract or expand items in each category.

    PROTIP: There are dozens of categories, so it may be easier to search for plugins by name or from the list of categories online at
    https://wiki.jenkins-ci.org/display/JENKINS/Plugins

    Install Green Balls icon plugin

  8. In the Filter field at the upper right of the screen, type “Green Balls”, which is one of the most popular among DevOps people who can’t stand that the Jenkins default for healthy (successful) is blue, not green. ( due to a historical/cultural artifact).

    PROTIP: When a plugin is installed, Jenkins removes that plugin among the “Available” and shows the plugin among the “Installed”.

  9. When you click the name of a plug-in you’ll be sent to another website, such as:
    https://wiki.jenkins-ci.org/display/JENKINS/Green+Balls

  10. Return to the previous screen: Hit the browser return key or command + left arrow.

    PROTIP: Instead of clicking plugin names, right-click to open link in New Tab on your browser so a tab with the Jenkins icon remains among browser tabs.

  11. Return to the root console page (by clicking “Jenkins” at the upper left corner).

  12. Click “S” among “S M L” under the icons to show Small icons.

    Install SCM plug-in

    Jenkins has plugins for many SCM systems: Accurev, Bazaar, BitKeeper, ClearCase, CMVC, Dimensions, Git, CA Harvest, Mercurial, Perforce, PVCS, StarTeam, CM/Synergy, Microsoft Team Foundation Server, and Visual SourceSafe.

  13. In Manage Jenkins, Manage Plugins, among Available, in Filter enter enough of “SCM Sync Configuration Plugin” to check it for install. Its URL is
    http://wiki.jenkins-ci.org/display/JENKINS/SCM+Sync+configuration+plugin

    “This plugin allows you to synchronize your hudson configuration files with an SCM, allowing you to specify a commit message every time a config file is modified.””

    NOTE: “Hudson” is still referenced even in Jenkins2. Just ignore it.

    Configure repo

  14. In Manage Jenkins, Configure System, notice

    /var/lib/jenkins

  15. In “SCM Sync Configuration”, select Git and type in the Git repo where your Jenkins configuration resides. In our example:

    https://github.com/hotwilson/box.git

    PROTIP: Jenkins should detect when there is a change to Jenkins configuration and update the repo with a pop-up commit message such as this:

  16. Check “Display SCM Sync Status”.

  17. Click Save.

    Git Plugin

  18. [0:42] Install “Git Plugin” https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin
    to provide Git client functionality on Jenkins servers.

  19. PROTIP: Restart Jenkins by changing the URL from:

    http://.../pluginManager/installed
    

    to

    http://.../restart
    

    Click Yes to “Are you sure”.

    “Please wait while Jenkins is restarting”.

Freestyle project

  1. [1:41] Create a Jenkins Freestyle project, OK.

  2. [2:01] The Source Code Management section, select Git.

  3. [2:15] Enter your repo, with the .git at the end.

    The plugin makes a call such as:

    git ls-remote -h https://github.com/hotwilson/box.git HEAD
    

    NOTE: When done on my Mac Terminal, this returns nothing.

    If you (like others) get the error message
    “Failed to connect to repository : Error performing command:”

  4. [2:15] If your repo is private, provide your SSH keys.

    https://developer.github.com/guides/managing-deploy-keys/

    https://docs.docker.com/docker-hub/builds/

Jenkins 2 Pipeline Plugin

Instead of manually clicking through the Jenkins UI, the Pipeline plugin in Jenkins 2 by author Jesse Glick (@tyvole) reads a text-based Jenkinsfile Groovy script code checked into source control.

  1. Install the “Pipeline” (in Manage Jenkins, Manage Plugins, Available) at
    https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Plugin

    NOTE: This was part of Cloudbees licenced features, but released in open edition.

  2. Right-click to open in a new tab the “See Pipeline as Code with Jenkins for more details” “link at
    https://jenkins.io/solutions/pipeline

  3. Return to the root console page (by clicking “Jenkins” at the upper left corner).

  4. Click New Item at http://…/view/All/newJob

    [TODO: jenkins2 new item menu 20160809 screen.png

  5. Enter item name and click “Pipeline”, then OK. (“Orchestrates long-running activities that can span multiple build slaves. Suitable for building pipelines (formerly known as workflows) and/or organizing complex activities that do not easily fit in free-style job type.”).

    When to build

  6. Among Build Triggers click “Build when a change is pushed to GitHub”.

  7. Click “GitHub project”.

  8. For Project url: https://github.com/hotwilson/box.git

    DEFINITION: The word “slave” has been replaced with the word “agent”.

    DEFINITION: A node is a step that schedules a task to run by adding it to the Jenkins build queue and allocating a workspace (file directory) on that node for the duration of the task.

    As soon as an executor slot is available on a node (the Jenkins master, or a slave), the task is run on that node.

  9. Click “Advanced” and type the Display name, “Box” in our example.

  10. Click “Pipeline” tab to bring that section up.

  11. Select from the “try sample” pull down “Hello World”.

    Notice the Groovy script:

    node {
    stage 'Stage 1'
    echo 'Hello World 1'
    stage 'Stage 2'
    echo 'Hello World 2'
    }
    
  12. Click Save for the item screen.

  13. Double-click on “Build Now” (in rapid succession).

    A sample response:

    NOTE: Text in headings were specified in state keywords in the Groovy script above.

    PROTIP: Only click once on Jenkins links or two executions will result from a double-click.

    Run results

  14. Cursor over one of the “ms” numbers (for milliseconds or thousands of a second) in the green area and click the Log button that appears.

    A pop-up appears with the text specified by the echo command within the Groovy script.

  15. Click the “X” at the upper-right of the dialog to dismiss it.

  16. To remove the menu on the left, click “Full Stage View”.

    PROTIP: The “full stage view” will be needed when there are more stages going across the screen.

    Build History

  17. To return to the menu with Build History,
    click the item/job name in the breadcrumbs or press command+left arrow.

  18. Click one of the jobs in the Build History section in http://…/job/box/5/

    Notice the number in the URL corresponds to the number listed.

    PROTIP: The time of the run is the server’s time, not your local time on your laptop.

  19. Click “Console Output” for log details created from that run.

NodeJS Plugin

https://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin

also installs Grunt http://gruntjs.com/getting-started

Plug-in files

  1. Switch to Terminal to open a new command line window and navigate to the hidden Jenkins folder to view files:

    
    cd ~/.jenkins
    cd plugins
    ls -al
    

    NOTE: Each plug-in has a .jpi binary file for each folder which contains a META-INF and WEB-INF folder.

  2. To provision a Docker box, this Gist script

    https://gist.github.com/micw/e80d739c6099078ce0f3

    does not require Jenkins to be running. It does the following:

    • Download one or more plugins to the plugin directory
    • Scan all plugins in that directory for missing dependencies to download those dependencies as well
    • Loop until no open dependencies are left.
  3. To install a Git client in the Console:

    
    curl -XPOST http://localhost:8080/pluginManager/installNecessaryPlugins -d ''
    

Rake Environment Variable

  1. In the Manage Jenkins menu, click Configure System.
  2. Check Environment variables under the Global properties section.
  3. Click Add.
  4. In the name value, type “PATH”.
  5. In the value field, type “$PATH /usr/local/bin” for Linux or OSX.

    Alternately, on Windows type “???”. TODO:

More plug-ins

Lists of top Jenkins plugins online: more plugins below.

  • http://www.praqma.com/stories/top-jenkins-plugins/
  • http://zeroturnaround.com/rebellabs/top-10-jenkins-featuresplugins/
  • https://uttamkini.com/2012/12/01/jenkins-plugins-that-every-team-must-use/
  • http://www.hugeinc.com/ideas/perspective/list-of-useful-jenkins-plugins
  • http://devops.com/2015/01/15/15-must-jenkins-plugins-increase-productivity/
  • https://wiki.jenkins-ci.org/display/JENKINS/Plugin+Installation+Statistics is broken

Base Plug-ins

  • Email Extension Plugin
  • Git Plugin
  • Graddle Plugin
  • SSH Slaves
  • Translation Assistance
  • Workspace Cleanup Plugin

For Microsoft developers

  • MSBuild
  • MSTest
  • MSTest Runner
  • VSTest Runner

Other plugins

Cloubees’ Study Guide PDF lists these plug-ins that all Certified Jenkins Engineers should know:


Safe Restart Plugin

Some install the SafeRestart plug-in which adds the Restart Safely option to the Jenkins left menu to avoid needing to be at the server console at all.

Clone Workspace

The Clone Workspace SCM Plugin
https://wiki.jenkins-ci.org/display/JENKINS/Clone+Workspace+SCM+Plugin clones Jenkins configurations for re-use in other projects.

See Cloudbees’s advice

JMeter plug-in

QUESTION: Are there more plug-ins for JMeter?

JMeter Performance Plug-in for JMeter

WARNING: This is no longer maintained, with a large bug list.

To add the Performance plug-in to display results from JMeter runs:

  1. Click the Manage Jenkins link.
  2. Click the Manage Plugins link.
  3. Select the Available tab.
  4. In Filter type “Performance”.
  5. Check to select “Performance plugin”.
  6. Click “Download now and install after restart”.
  7. Click to restart server.

If you prefer a manual approach:

  1. Create a folder to hold the folder created during cloning (such as jmeter or jenkinsci).
  2. cd to that folder, then:

    git clone https://github.com/jenkinsci/performance-plugin.git performance
    cd performance
    

    This contains a pom.xml file for Maven to compile the src folder.

  3. If you haven’t already:

    brew install maven
    
  4. Compile in a command window:

    mvn package
    

    This downloads a bunch of files specified as dependencies, ending in this:

    [INFO] Total time: 09:20 min
    [INFO] Finished at: 2016-01-26T08:31:04-08:00
    [INFO] Final Memory: 52M/259M
    
  5. Get the address of the Jenkins server. To find (ignoring case)

    find . -iname "jenkins.war"
    
  6. Copy to the target server the .hpi file which defines a plug-in:

    cp <target>/performance.hpi <path_to_jenkins>/data/plugins
    
  7. To fix this switching report format to xml in jmeter properties file:

    jmeter.save.saveservice.output_format=xml
    
  8. Configure the search pattern to select the files to be parsed by the Performance plugin. JMeter generates .jtl files.

  9. Configure the error percentage thresholds which would make the project unstable or failed

  10. When no jobs are running, restart the Jenkins server to reload the plugin.

Read more about plugins

  • http://wiki.jenkins-ci.org/display/JENKINS/Checking+out+existing+plugins
  • http://wiki.jenkins-ci.org/display/JENKINS/Plugin+tutorial
  • http://wiki.jenkins-ci.org/display/JENKINS/Hosting+Plugins
  • https://www.blazemeter.com/blog/continuous-integration-101-how-run-jmeter-jenkins
  • https://www.linkedin.com/pulse/continuous-automated-web-tests-using-jenkins-jmeter-mahanta

  • https://dzone.com/articles/orchestrating-workflows-with-jenkins-and-docker

  • https://github.com/jenk

  • http://udaypal.com/jenkins-workflow-getting-started/

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