Download presentation
Presentation is loading. Please wait.
Published byFelicity Watkins Modified over 5 years ago
1
JENKINS TIPS Ideas for making your life with Jenkins easier
2
JENKINS TIPS November 2014
3
“ When presented with a choice, pick a solution that’s easy to configure and maintain. ”
(Me, just now)
4
DISCLAIMER: This presentation is not meant to be regarded as scripture. Instead, it captures the author’s personal preferences when dealing with Jenkins as a Continuous Integration server. Working software not releasable software - the code will be carried forward, re-factored and hardened for the first release.
5
CONTENT TABLE The presentation is divided into two big chapters:
1. Jenkins configuration 2. Jenkins project configuration Internal Only
6
1. Jenkins configuration
1.a Jenkins installation 1.b Post install configuration Internal Only
7
Standalone installation vs. Deploying to an application server
1.a) Jenkins installation Standalone installation vs. Deploying to an application server Standalone installation: Native package available for Windows, MacOS and most popular Linux/BSD distros On Windows, Jenkins is installed as an independent service, and it is configured to start automatically upon system boot Deploying to an application server potential advantages: no extra port used :) slightly lower RAM usage, in theory
8
Editing Jenkins’ configuration file
1.b) Post install configuration Editing Jenkins’ configuration file The jenkins.xml file is located in Jenkins' installation folder (Windows 32-bit default: C:\Program Files (x86)\Jenkins\). Recommended : change Jenkins' HTTP port from its default value of 8080 (to prevent current / future Tomcat conflicts) Optional: change java version / java arguments (i.e -XX:-UseGCOverheadLimit -Dmail.smtp.starttls.enable="true" -Xms256m -Xmx512m -XX:MaxPermSize=512m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled)
9
Running Jenkins as “Local System” vs. Using a dedicated account
1.b) Post install configuration Running Jenkins as “Local System” vs. Using a dedicated account The Windows “Jenkins” service runs as the “Local System” user by default; change it to a dedicated account to get rid of PATH-related headaches (i.e. missing folders/configuration files for Maven / Ant builds; personal experience with grunt (JS build tool))
11
Jenkins Global Settings
1.b) Post install configuration Jenkins Global Settings ( The Global Settings screen exposes a limited set of basic configs, including: - workspace / build root directories - number of executors: number of concurrent build jobs - JDK, ANT, Maven installations This screen will also be used for configuring additional plugins.
12
Updating Jenkins and plugins
1.b) Post install configuration Updating Jenkins and plugins Often, when accessing the “Manage Jenkins” section, you will be greeted with the following screen:
13
Updating Jenkins and plugins
1.b) Post install configuration Updating Jenkins and plugins Personal suggestions for updating Jenkins / plugins: Jenkins: go right ahead, you can always downgrade if needed (which shouldn’t happen very often) plugins: don’t fix it if it’s not broken - I wouldn’t recommend updating plugins for no good reason, especially after you start configuring projects using those plugins (as a practical example, Jenkins comes with a 1.x version of the SVN plugin, while early versions of the 2.x plugin did not support SVN format 1.8)
14
Installing additional plugins
1.b) Post install configuration Installing additional plugins ( Useful plugins: 1) pre-scm-buildstep – allows running tasks before code checkout 2) Deploy to container plugin – deploy war to application server 3) -ext plugin – provides an upgrade over the default plugin, being more configurable 4) GitHub Plugin – adds Git support (Jenkins doesn't support Git repositories out of the box) 5) Gradle Plugin – adds Gradle support 6) Cucumber Reports Plugin – adds support for creating "pretty" Cucumber reports
15
Configuring the email-ext plugin for a gmail account
1.b) Post install configuration Configuring the -ext plugin for a gmail account
16
2. Project configuration
2.a “Staging” environment 2.b Managing disk usage 2.c Downstream projects 2.d Using scripts 2.e Build triggers 2.f notifications Internal Only
17
2.a) “Staging” environment
Test project updates in a “staging” environment before applying them to your “production” Jenkins! However, if the “staging” environment is on a development machine, make sure you keep your workspaces separated; don’t check “Advanced Project Options - Use custom workspace” (personal experience with conflict between IntelliJ IDEA – which uses the locally installed SVN client – and Jenkins – which uses its SVN plugin)
18
Out of the box, Jenkins keeps everything forever!
2.b) Managing disk usage Out of the box, Jenkins keeps everything forever! Check "Days to keep artifacts" / "Max # of builds to keep with artifacts" (as appropriate) if you only want to delete artifacts (war,jar,zip) but keep logs/reports for project metrics! N.B: Depending on project specifics, additional clean up may be required (e.g. C:\Windows\Temp)
19
Keeping build and automated tests projects separated
2.c) Downstream projects Keeping build and automated tests projects separated Define independent projects for build / automated tests Use "Build other project" post-build action on the main build, check "Block build when downstream project is building" Advanced option Only include a small set of smoke tests to run for each build; run full automated regression for the "nightly" build
20
Can be executed before/during/after build
2.d) Using scripts Highly recommended for control freaks (can be used to replace some plugins, e.g. deploy, which fails sometimes) Can be executed before/during/after build For project independence, use embedded scripts if you don't want to keep track of your files
21
Build triggering strategies:
2.e) Build triggers Build triggering strategies: Use “Build periodically” for “nightly” builds “Poll SCM” for everything else For impatient people, builds can be triggered “on commit” - copy .git\hooks\post-commit.sample to .git\hooks\post-commit - add the following line to the post-commit file: “curl
22
2.f) Email notifications
Don’t spam! Only send notifications for failed builds (configure trigger in the extended plugin’s “Advanced Settings”)
23
Q & A
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.