Plugins
CJE Exam is based on Suggested plugin list -https://github.com/jenkinsci/jenkins/blob/jenkins-2.19.4/core/src/main/resources/jenkins/install/platform-plugins.json
Suggested Plugin
Organization and Administration
Dashboard View
https://wiki.jenkins-ci.org/display/JENKINS/Dashboard+View
This plugin contributes a new view implementation that provides a dashboard / portal-like view for Jenkins.
CloudBees Folders Plugin
https://wiki.jenkins-ci.org/display/JENKINS/CloudBees+Folders+Plugin
This plugin allows users to create "folders" to organize jobs. Users can define custom taxonomies (e.g. by project type, organization type). Folders are nestable and you can define views within folders.
OWASP Markup Formatter Plugin (antisamy-markup-formatter)
https://wiki.jenkins-ci.org/display/JENKINS/OWASP+Markup+Formatter+Plugin
Uses policy definitions to allow limited HTML markup in user-submitted text.
Configuration
Once installed 'Safe HTML' can be selected as Markup Formatter. User-submitted text will be sanitized by removing dangerous elements.
Build Features
Build timeout
https://wiki.jenkins-ci.org/display/JENKINS/Build-timeout+Plugin
This plugin allows you to automatically abort a build if it's taking too long. Once the timeout is reached, Jenkins behaves as if an invisible hand has clicked the "abort build" button.
Instructions:
After installing the plugin, go to the configure page for your job and select "Abort the build if it's stuck".
Credentials Binding
https://wiki.jenkins-ci.org/display/JENKINS/Credentials+Binding+Plugin
Allows credentials to be bound to environment variables for use from miscellaneous build steps.
You may have a keystore for jarsigner, a list of passwords, or other confidential files or strings which you want to be used by a job but which should not be kept in its SCM, or even visible from its config.xml. Saving these files on the server and referring to them by absolute path requires you to have a server login, and does not work on slaves. This plugin gives you an easy way to package up all a job’s secret files and passwords and access them using a single environment variable during the build.
To use, first go to the Credentials link and add items of typeSecret file_and/or_Secret text. Now in a freestyle job, check the box_Use secret text(s) or file(s)_and add some variable bindings which will use your credentials. The resulting environment variables can be accessed from shell script build steps and so on. (You probably want to start any shell script withset +x
, or batch script with@echo off
.JENKINS-14731). https://wiki.jenkins-ci.org/display/JENKINS/Credentials+Binding+Plugin
Time stamper
https://wiki.jenkins-ci.org/display/JENKINS/Timestamper
Adds timestamps to the Console Output.
Instructions
Enable time stamps within the "Build Environment" section of the build's configuration page.
To enable timestamps for multiple builds at once, use the Configuration Slicing Plugin version 1.32 or later.
Customization
The timestamp format can be configured via the
Configure System
page.There is a panel on the left-hand side of the console page which allows either the system clock time or the elapsed time to be displayed.
The time zone used to display the timestamps can be configured by setting a system parameter as described here: Change time zone
Workspace Cleanup Plugin (ws-cleanup)
This plugin deletes the workspace before the build or when a build is finished and artifacts saved.
Option for deleting workspace before build is in Build Environment section. https://wiki.jenkins-ci.org/display/JENKINS/Workspace+Cleanup+Plugin
Build Tools
Ant Plugin
https://wiki.jenkins-ci.org/display/JENKINS/Ant+Plugin
This plugin adds Apache Ant support to Jenkins. This functionality used to be a part of the core, but as of Jenkins 1.431, it was split off into separate plugins.
Apache Ant is a Java library and command-line tool whose mission is to drive processes described in build files as targets and extension points dependent upon each other. The main known usage of Ant is the build of Java applications. Ant supplies a number of built-in tasks allowing to compile, assemble, test and run Java applications. Ant can also be used effectively to build non Java applications, for instance C or C++ applications. More generally, Ant can be used to pilot any type of process which can be described in terms of targets and tasks.
Installation
For this plugin to be used, an Ant installation must be specified in the global Jenkins configuration. It can be installed automatically:
Gradle
https://wiki.jenkins-ci.org/display/JENKINS/Gradle+Plugin
This plugin (Build Tool) makes it possible to invoke a Gradle build script as the main build step.
Description
This plugin adds Gradle Support to Jenkins. Gradle is managed as another tool inside Jenkins (the same way as Ant or Maven),
including support for automatic installation and a new build step is provided to execute Gradle tasks.
Configuration
Gradle configuration is performed in the Configure System(before Jenkins 2.0) or Global Tool Configuration(starting in Jenkins 2.0). In both cases these options reside in the Manage Jenkins section.
In the Gradle section provided by this plugin, several installations can be configured:
Pipelines and Continuous Delivery
Pipeline Plugin
https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Plugin
A suite of plugins that lets you orchestrate automation, simple or complex.
Syntax Reference: https://jenkins.io/doc/book/pipeline/syntax/
GitHub Organization Folder Plugin
https://wiki.jenkins-ci.org/display/JENKINS/GitHub+Organization+Folder+Plugin
Pipeline-as-Code support for a whole GitHub organization. Scans all the branches & repositories in GitHub organization and build them via Jenkins pipelines automatically.
Notes
To determine the branch being built - use the environment variableBRANCH_NAME
- e.g.${env.BRANCH_NAME
}
Pipeline Stage View Plugin
https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Stage+View+Plugin
When you have complex builds Pipelines, it is useful to be able to see the progress of each stage. The Pipeline Stage View plugin includes an extended visualization of Pipeline build history on the index page of a flow project, under Stage View. (You can also click on Full Stage View to get a full-screen view.)
To take advantage of this view, you need to define stages in your flow. You can have as many stages as you like, in a linear sequence. (They may be inside other steps such as 'node' if that is convenient.) Give each a short name that will appear in the GUI.
Source Code Management
Git Plugin
https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin
This plugin allows use of Git as a build SCM, including repository browsers for several providers. A recent Git runtime is required (1.7.9 minimum, 1.8.x recommended). Interaction with the Git runtime is performed by the use of the Git Client Plugin, which is only tested on official git client. Use exotic installations at your own risk.
Global Settings
In the Configure System page, the Git Plugin provides the following options
- Global Config user.name Value: if provided git config user.name <value> is called before builds. This can be overridden by individual projects.
- Global Config user.email Value: if provided git config user.email <value> is called before builds. This can be overridden by individual projects.
- Create new accounts base on author/committer's email: if checked, upon parsing of git change logs, new user accounts are created on demand for the identified committers / authors in the internal Jenkins database. The e-mail address is used as the id of the account.
A Repository Browser can also be configured, which adds links in "changes" views within Jenkins to an external system for browsing the details of those changes. The "Auto" selection attempts to infer the repository browser from other jobs, if supported by the SCM and a job with matching SCM details can be found, though it can also be selected manually.
Subversion plugin
https://wiki.jenkins-ci.org/display/JENKINS/Subversion+Plugin
This plugin adds the Subversion support (via SVNKit) to Jenkins.This plugin is bundled inside jenkins.war
Basic Usage
Once this plugin is installed, you'll see Subversion as one of the options in the SCM section of job configurations.
Distributed Builds
SSH Slaves Plugin
https://wiki.jenkins-ci.org/display/JENKINS/SSH+Slaves+plugin
This plugin allows you to manage slaves running on *nix machines over SSH. It adds a new type of slave launch method. This launch method will
- Open a SSH connection to the specified host as the specified username.
- Checks the default version of java for that user.
- [not implemented yet] If the default version is not compatible with Jenkins's slave.jar, tries to find a version of java that is.
- Once it has a suitable version of java, copies the latest slave.jar via SFTP (falling back to scp if SFTP is not available)
- Starts the slave process.
User Management and Security
Matrix Authorization Strategy Plugin
https://wiki.jenkins-ci.org/display/JENKINS/Matrix+Authorization+Strategy+Plugin
Offers matrix-based security authorization strategies (global and per-project).
Also checkout https://wiki.jenkins-ci.org/display/JENKINS/Matrix-based+security for more details.
Matrix-based security is one of the authorization strategies available for securing Jenkins. It allows you to grant specific permissions to users and groups.
PAM Authentication Plugin
https://wiki.jenkins-ci.org/display/JENKINS/PAM+Authentication+Plugin
Adds Unix Pluggable Authentication Module (PAM) support to Jenkins.
LDAP Plugin
https://wiki.jenkins-ci.org/display/JENKINS/LDAP+Plugin
This plugin provides yet another way of authenticating users using LDAP. It can be used with LDAP servers like Active Directory or OpenLDAP among others.
Notifications and Publishing
Email-ext plugin
https://wiki.jenkins-ci.org/display/JENKINS/Email-ext+plugin
This plugin allows you to configure every aspect of email notifications. You can customize when an email is sent, who should receive it, and what the email says.
This plugin extends Jenkins built in email notification functionality by giving you more control. It provides customization of 3 areas.
- Triggers - Select the conditions that should cause an email notification to be sent.
- Content - Specify the content of each triggered email's subject and body.
- Recipients - Specify who should receive an email when it is triggered.
Mailer plugin
https://wiki.jenkins-ci.org/display/JENKINS/Mailer
This plugin allows you to configure email notifications for build results. This is a break-out of the original core based email component.
Usage
E-Mail notifications are configured in jobs by adding an E-mail notification Post-build Action. If configured, Jenkins will send out an e-mail to the specified recipients when a certain important event occurs:
- Every failed build triggers a new e-mail.
- A successful build after a failed (or unstable) build triggers a new e-mail, indicating that a crisis is over.
- An unstable build after a successful build triggers a new e-mail, indicating that there's a regression.
- Unless configured, every unstable build triggers a new e-mail, indicating that regression is still there.
The Recipients field must contain a whitespace or comma-separated list of recipient addresses. May reference build parameters like$PARAM
.
Additional options include:
- Send e-mail for every unstable build : if checked, notifications will be sent for every unstable build and not only int first build after a successful one.
Send separate e-mails to individuals who broke the build : if checked, the notification e-mail will be sent to individuals who have committed changes for the broken build (by assuming that those changes broke the build).
If e-mail addresses are also specified in the recipient list, then both the individuals as well as the specified addresses get the notification e-mail. If the recipient list is empty, then only the individuals will receive e-mails.
Build Periodically and Trigger Schedule (CRON Syntax)
This field follows the syntax of cron (with minor differences). Specifically, each line consists of 5 fields separated by TAB or whitespace:
MINUTE HOUR DOM MONTH DOW
MINUTE | Minutes within the hour (0–59) |
---|---|
HOUR | The hour of the day (0–23) |
DOM | The day of the month (1–31) |
MONTH | The month (1–12) |
DOW | The day of the week (0–7) where 0 and 7 are Sunday. |
To specify multiple values for one field, the following operators are available. In the order of precedence,
*
specifies all valid valuesM-N
specifies a range of valuesM-N/X
or*/X
steps by intervals of X through the specified range or whole valid rangeA,B,...,Z
enumerates multiple values
To allow periodically scheduled tasks to produce even load on the system, the symbolH
(for “hash”) should be used wherever possible. For example, using0 0 * * *
for a dozen daily jobs will cause a large spike at midnight. In contrast, usingH H * * *
would still execute each job once a day, but not all at the same time, better using limited resources.
TheH
symbol can be used with a range. For example,H H(0-7) * * *
means some time between 12:00 AM (midnight) to 7:59 AM. You can also use step intervals withH
, with or without ranges.
TheH
symbol can be thought of as a random value over a range, but it actually is a hash of the job name, not a random function, so that the value remains stable for any given project.
Beware that for the day of month field, short cycles such as*/3
orH/3
will not work consistently near the end of most months, due to variable month lengths. For example,*/3
will run on the 1st, 4th, …31st days of a long month, then again the next day of the next month. Hashes are always chosen in the 1-28 range, soH/3
will produce a gap between runs of between 3 and 6 days at the end of a month. (Longer cycles will also have inconsistent lengths but the effect may be relatively less noticeable.)
- Empty lines and lines that start with
#
will be ignored as comments.
In addition,@yearly
,@annually
,@monthly
,@weekly
,@daily
,@midnight
, and@hourly
are supported as convenient aliases. These use the hash system for automatic balancing. For example,@hourly
is the same asH * * * *
and could mean at any time during the hour.@midnight
actually means some time between 12:00 AM and 2:59 AM.
Examples:
# every fifteen minutes (perhaps at :07, :22, :37, :52)
H/15 * * * *
# every ten minutes in the first half of every hour (three times, perhaps at :04, :14, :24)
H(0-29)/10 * * * *
# once every two hours at 45 minutes past the hour starting at 9:45 AM and finishing at 3:45 PM every weekday.
45 9-16/2 * * 1-5
# once in every two hours slot between 9 AM and 5 PM every weekday (perhaps at 10:38 AM, 12:38 PM, 2:38 PM, 4:38 PM)
H H(9-16)/2 * * 1-5
# once a day on the 1st and 15th of every month except December
H H 1,15 1-11 *
If you want to schedule your build every 5 minutes, this will do the job :*/5 * * * *
If you want to schedule your build every day at 8h00, this will do the job :0 8 * * *
***Git Hooks with Git and Github Plugin****
Git plugin
Jenkins:
- Check Poll SCM
- No need to add anything in the schedule.
Github:
- Project->Setting->Integration & Services->Add Services-> Jenkins (git plugin)
- Jenkins url: http://jenkins_url:8080
Github plugin
Jenkins:
- Project-> Check Github hook trigger for GitSCM polling
Github:
- Project->Setting->Integration & Services->Add Services-> Jenkins (Github plugin)
- Jenkins url: http://jenkins_url:8080/github_webhook/
- Make sure Active box is checked.
- Can test the integration by clicking on the Test Service.
In Jenkins, you can now check the Github Hook Log.