This chapter takes a hands-on approach to create Jenkins jobs.
First, we assume Jenkins server was setup in jenkins-setup.
We begin with a look at an existing build job and its run history details as we learn navigation tricks.
## Tabs If there are a lot of jobs listed (especially on a Jenkins server shared by many):-
Group jobs into separate page views, click on the [+] tab above the list of projects.
-
Views can also be selected after clicking the tiny righ-pointing arrow to the left of Jenkins on the green bar.
-
Best to be in a View before you create an item within that view.
-
Click the New Item link on the left menu.
PROTIP: In the description field, put a link to the wiki page which describes the logic for selections made in the project and/or the standards document mandating selections.
Check out
## Hierarchy of Projects/Jobs to Individual Builds CHALLENGE: Become famailiar with operations available in menus and links at different levels of the hierachy.-
For smaller icons, click the S among S | M | L at the bottom of the list.
-
Disable auto-refresh at the upper-right of the jobs list so you are not disturbed.
NOTE: Several teams typically share use of the same Jenkins server.
-
Mouse over the # link for the top row on the job list and select the tiny arrow that appears.
-
Select an option from the context menu that appears:
PROTIP: Viewing a specific run is more frequently done that reviewing historical trends.
-
Select from the context menu Console Output for the particular run clicked.
This is the lowest detail to each run. Lines output are from the program that was invoked, not Jenkins.
-
Click Back to Dashboard to return to the Jobs/Projects list.
## Job Screen - builds -
Click on an existing job Name to see its status screen.
CAUTION: If you're just looking around, don't click the Disable button on the right nor the Delete button on the left menu.
-
Clicking Recent Changes on the Status screen is the same as clicking Changes on the left menu.
PROTIP: The same link can appear in the left menu and in the screen. Prefer the left menu as it's easier to remember and to find.
-
Return to the higher level projects screen by clicking on another left menu item, such as Workspace.
### Item Context Workspace -
In addition to the choice of clicking either Workspace link to view input files (pulled from Github), click the tiny drop-down arrow for a context menu.
The workspace shown was obtained from the last build.
### Workspace ConfigurationPROTIP: Being able to pull down a workspace is the first achievement of a new job.
-
Click the Configure link at the left menu for values in the form used to create the current job.
-
Mouse over the green breadcrumbs line to the right of Configure for a menu:
PROTIP: Using the drop-down menu from the breadcrumbs green bar saves you from scrolling down the many pages in this screen.
-
Select Source Code Management.
-
Select Git. This also applies to github.
-
Specify the Repository URL, such as
[email protected]:Project1/repo1.git
.PROTIP: Private (corporate) repos use this format for more secure communications.
-
In Credentials enter a user name. Click Add.
PROTIP: Rather than using individual accounts that expire, create service accounts that do not expire.
-
In Branches to build, specify
*/master
or whatever branch you use. -
Scroll to Build Environment section.
-
Check Delete workspace before build starts.
### Build project to obtain Workspace -
Click to build the project.
-
Click Workspace to determine if the Workspace was pulled into Jenkins.
-
The full Git commit ID should appear in the build page.
Only the first 7 characters is usually displayed in git clients.
-
In the Console Output:
### Configure project[description-setter] Could not determine description.
-
Scroll down to the String Parameter names and default values (such as environment, browsertype).
PROTIP: Pay special attention whether the first letter of each parameter values are capitalized.
### Parameters -
Click the Build with Parameters link at the left menu for a list of parameter values fed to the job.
CAUTION: Don't click Build if you're just looking around because that invokes the build job.
More parameters can be added in Configure:
(These are explained eleswhere.)
PROTIP: Even though a page doesn't have a "Cancel" action (just Save or Apply), exit without saving by clicking another menu item.
-
Escape the page without saving by clicking another menu item, the Coverage Trend link at the left menu.
It does not display much if the add-on is not installed.
-
Click the "Last build" under Permanlinks. Notice it is a generic link for the link at the top of the Build History at the left.
-
Click Parameters to review the parameter values used in this particular run.
-
Click Git Build Data for the code which uniquely identifies the data used to drive this particular build.
-
Click the # listed in the breadcrumbs bar.
-
Click Git Build Data for the same information.
-
Click the link to the job in the breadcrumbs bar to skip a level up.
-
Click the job name in the cookie crumbs link at the top to return to the job status screen.
-
Click a run # on the left menu.
Notice it's an expansion of items shown in the Workspace shown above.
-
Click History on the left menu.
This lists the history for each run its duration and count of steps in each run. These details are not shown in the list at the job level.
-
In the Dashboard list, click on the (tiny) drop-down button for the drop-down context menu of a project.
-
Select Configure.
PROTIP: "Continuous integration" approaches typically favor Build after other projects are built to remove the time window between developers building and Jenkins running tests.
WARNING: "Poll SCM" (SCM = Source Code Management system) incurs overhead to service polling checks from Jenkins.
-
Click Build periodically.
PROTIP: Periodic builds are used when testing is disassociated from those who make changes.
Jenkins makes use of 5 timing codes separated by spaces. The first position specifies the minute. The second the hour, etc. A code such as "H H(9-10) * * *" specifies runs with H to specify use of a hash calculation of the job name that randomizes a time between 9 and 10 am.
-
Click on the blue question mark for more detail.
-
A build job can still be always be invoked manually anytime.
-
Click Configure in the context menu or in the left menu.
- Click on a plug-in category name to collapse or expand its items ("Source Code Management", etc.). But no need to click on them all. A list of categories is at http://wiki.jenkins-ci.org/display/JENKINS/Plugins
Locks and latches are explicity "gates" to control which jobs run in parallel.
Copy artifacts duplicates files.
## Build Add-ons These are for JMeter:-
https://github.com/jmeter-maven-plugin/jmeter-maven-plugin from https://github.com/mlex/jmeter-maven-example/
-
http://mojo.codehaus.org/chronos/chronos-jmeter-maven-plugin/
Michael Lex lists the evaluation criteria:
- The plugin should not depend on a local JMeter installation.
- It must be possible to start the JMeter test from command line (without gui). With the jmeter-maven-plugin, a simple additional dependency to kg.apc:jmeter-plugins allowed using the JMeter Plugins in GUI as well as in headless mode.
- The JMeter GUI should also be accessibla directly via the plugin (e.g. via a separate Maven goal).
- It should be possible to include the JMeter Plugins.
- The plugin should generate meaningful reports (or there must be some other possibility to generate these reports).
Additional:
- generate graphs from the test results using the jmeter plugins CMDRunner.
In a Configure screen:
-
Scroll down to the Build section.
-
Cursor over a build step such as "Build a Visual Studio project".
-
For MSBuild Build File, the file extension should be .sln (solution).
-
In "Run unit tests with MSTest", test file extension should be .dll (dynamic link library).
-
The Results.trx file extension is ".trx".
-
In "Execute Windows Batch command", the Command is first an .exe (executable).
C:\Tools\trx2html.exe Results.trx
-
In "Publish MSTest test result report", it's *.trx.
-
Click Add Build Step.
- For Label Expression, enter WindowsHost to only run on Windows machines.
- https://wiki.jenkins-ci.org/display/JENKINS/Performance+Plugin sets the final build status (as good, unstable or failed) based on the reported error percentage.
-
In the post-build actions, to update the results of the build back to a central git repo, select "Push GIT tags back to origin repository".
In the workspace for a project are folders and .trx files output from Jenkins runs.
If a job fails,
-
Email notifications are sent if Editable Email Notification is selected.
-
Parameters defined earlier can be specified in the Default Content field:
Results For Build $BUILD_ID
* SMS via PagerDuty.
PROTIP: Email to a distribution list broadcasting to a small number of people
or only whoever is on-call.
* https://github.com/jenkinsci/slack-plugin
can be installed to send chat room (Slack) notifications.
<a name="Wrappers">
## Wrappers</a>
Invoke **Prepare for Shutdown** to stop work, to avoid abruptly stopping jobs.
Wrappers start a parallel process before a job starts and shuts it down when the job is done.
include Selenium RC
VMWare
VirtualBox
in which to run the Jenkins job.
Notifiers
<a id="Reports">
## Reports</a>
0. Builds appear in the **Build Queue** at the left of the UI.
0. Right-click on the # associated with a build for a drop-down list.
<img width="611" alt="jenkins-build-project-detail" src="https://cloud.githubusercontent.com/assets/300046/11172332/02c5ca5a-8bc3-11e5-8d53-b4a0b57a22a8.png">
0. Select **Console Output** to view the log from each build.
Jenkins provides RSS feeds exposing XML files containing lists of just failures or a list of just the latest builds.
0. A link to a specific build attempt is like this example generated from Papercut.codeplex.com:
http://localhost:8081/job/Hellow%20World/27/
<a id="Artifactory">
## Output to Artifactory</a>
* https://wiki.jenkins-ci.org/display/JENKINS/Artifactory+Plugin
<a id="Resources">
## Resources for further learning</a>
By Chandra Shekhar Reddy:
* https://www.youtube.com/watch?v=XY-ZB3FRnxw
Jenkins Tutorial - Part 01: Introduction & installation by Chandra Shekhar Reddy
* https://www.youtube.com/watch?v=XY-ZB3FRnxw (19:25) Install JRE8 & Jenkins.war on Windows & /opt/tomcat7/webapps
and ./bin/startup.sh
* https://www.youtube.com/watch?v=RR0LabeUQ88 Create New Job in Jenkins on Windows.
* Configuring jobs- https://www.youtube.com/watch?v=vJqUwZpRqwo
* Git integration https://www.youtube.com/watch?v=ISAUsBSI8G0
* Configuring slave nodes https://www.youtube.com/watch?v=EOp2VVRHrKQ
By Chris Chrysostom:
* https://www.youtube.com/watch?v=RR0LabeUQ88 Create new job in Jenkins
John Sonmez (@jsonmez, http://simpleprogrammer.com/)
* <a target="_blank" href="https://app.pluralsight.com/library/courses/jenkins-introduction/table-of-contents">
Getting Started with Jenkins Continuous Integration 2-hour 38-minute video course Feb. 2013 at Pluralsight.com</a>.
So he is showing an older 1.500 version of Jenkins.
In this course, examples use SVN (Subversion) for the SCM (Source Control Manager), Visual Studio,
MSBuild (), MSTest, MSTestRunner, StyleCop, and Papercut.
But other tools work in a similar way.
The sln (solution) MSBuild script file in the video can be an Ant or Maven script.
<img alt="jenkins-job-flow-diagram" src="https://cloud.githubusercontent.com/assets/300046/11226898/b5a246f6-8d37-11e5-86f4-1c75e6c49dee.png">
http://app.pluralsight.com/courses/jenkins-introduction
* http://thepracticalsysadmin.com/setting-up-a-github-webhook-in-jenkins/
* https://gist.github.com/misterbrownlee/3708738
Jenkins to build GitHub projects.
<a id=SkillCert">
## Skill Certification</a>
The company hosting Jenkins servers is also hoisting certifications of Jenkins people.
There is the age-old question of whether organizations providing training also be the one offering certifications
advertised as being of the whole community.
The company is so commercial oriented that it does not allow newsletters to be sent to gmail and hotmail addresses.
John Ferguson Smart (O'Reilly) used DocBook and
XmlMind to write http://www.github.org/wakaleo/jenkins-the-definitive-guide
also available as a free pdf download from http://wakaleo.com/books/jenkins-the-definitive-guide/download-jtdg-pdf