Professional Documents
Culture Documents
Lab-3 (Installing Maven in Jenkins)
Lab-3 (Installing Maven in Jenkins)
Lab-3 (Installing Maven in Jenkins)
Our Jenkins server is not yet configured to send email messages. In order to take
advantage of the several useful build notification features provided by Jenkins we
will need to set our lab system up with mail services and then configure Jenkins to
use them.
This lab will walk you through some common Jenkins server configuration tasks
and help you gain familiarity with Jenkins server setup and the ways that Jenkins
manages configuration settings. First, we will configure Jenkins to use Maven and
then we will setup Jenkins mail services.
We now have maven 3.3.9 installed with a home directory set to /usr/share/maven.
2
1. Open a browser and point it at your Jenkins server. From the dashboard select “Manage
Jenkins” and choose “Manage Plugins”
Go to Available and on top Search for Maven and select only maven integration
plugin and choose to install without restart:
3
STEP3: Go back to dashboard and select manage plugins and choose Global
Tool Configuration
• Scroll down to search for maven and in your Terminal enter
maven –version
4
Add a maven installation to your system with the name “Maven 3.3.9” and the
correct MAVEN_HOME path reported by the mvn --version command (be sure
to uncheck install automatically).
Save your changes by clicking the “Save” button at the bottom left of the
configuration page.
STEP4- Test your Maven Installation
From the Jenkins Dashboard create a new project, name it maventest and select the
maven project type
5
Without changing the configuration, click save to create your project. If this works
you have correctly configured Jenkins with Maven. Without a valid Maven
configuration Jenkins will not allow you to create a maven project. Also, if there are
multiple Maven configurations Jenkins will require you to choose the version to use
with your new project.
Leave all of the projects defaults in place and save the new maventest project. When
the project page is displayed click the “Delete Maven project” link from the
navigation bar at the left of the page to delete the project.
The package installer automatically runs the configuration utility. Configure the
server for local only delivery:
This will set up a mail server that will accept mail only for local users.
Next set the host name for the mail system. Normally this would be myco.com or
some such, but for our purposes we can just use the default Ubuntu host name
“ubuntu”.
When the installation completes, test the mail server using the mail command line
client to send an email to “user” on the localhost “ubuntu”:
echo "This is the body of the email" |mail -s "this is the Subject line" ubuntu@ubuntu
This sends the echoed string with the subject specified by the mail -s switch to the
mailbox for “user” on the host “ubuntu”.
Now read you mail using the main command line mail reader (yes, people actually
used to read their mail at the command prompt):
8
To delete the most recently displayed message we use the “d” command. To quit
the mail utility, we use the “q” command. You can get help with the mailer by
typing “?”.
From the Jenkins home page click the “Manage Jenkins” link in the left-hand side
navigation bar.
9
Scroll to the bottom of the configuration page and locate the “E-mail Notification”
section. Enter “localhost” as the SMTP server and “@ubuntu” as the default e-mail
suffix. Finally click the “Test configuration by sending test e-mail” check box and
specify the “user” user as the email target. Finally click the “Test configuration”
button at the bottom right to test the email settings:
You can configure a “reply to” address and other settings in the advanced block
using the “Advanced…” button but we do not need to configure any of the
advanced settings for our configuration. Save your configuration changes by
clicking the “Save” button at the bottom left.
Now return to the lab machine command prompt and check your mail:
10
Success! You now have your Jenkins server configured to send email automatically.
Jenkins maintains essentially all of its server configuration settings in xml files
found in JENKINS_HOME.
As you can see there are a number of .xml files. The config.xml is the main Jenkins
configuration files. This file contains less and less over time because all of the
functions that Jenkins orchestrates are either currently or soon to be migrated to
plugins. Jenkins being therefore the framework within which build plugins are
managed.
For example, to see our Mailer configuration settings you can display the
hudson.tasks.Mailer.xml file contents:
cat .jenkins/hudson.tasks.Mailer.xml
12
cat .jenkins/hudson.tasks.Maven.xml
While it is not generally necessary to edit these files directly, knowing your way
around makes it easier to fix problems, clone and backup configurations among
other administrative tasks.