DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. A Getting Started Guide to Setting up Jenkins

A Getting Started Guide to Setting up Jenkins

Check out this guide on how to get started with arguably the most important part of any Continuous Integration pipeline.

Greg Sypolt user avatar by
Greg Sypolt
·
Sep. 21, 16 · Tutorial
Like (21)
Save
Tweet
Share
21.79K Views

Join the DZone community and get the full member experience.

Join For Free

the goal of this getting started guide is to help teams get jenkins continuous integration (ci) servers configured and discover how to make a newly deployed ci infrastructure fully operational. jenkins is a leading open source ci server. it is flexible, providing hundreds of plugins to support building, testing, and deployment, and is capable of automating any project. jenkins ci infrastructure can be deployed to on-prem, in the cloud using configuration management tools, and third-party vendor. for the purpose of this article, let’s assume that our jenkins ci servers are deployed in the cloud and focus on configuration of jenkins’ web interface. i will walk through various processes and steps to set up a new jenkins ci server for production.

recommended best practices for ci architecture

don’t jump head first into configuration and creating a pipeline without planning, designing, and establishing standards for your ci architecture. taking the time to think about infrastructure first will enable a stable and restorable infrastructure. let’s review a few recommended best practices to consider in your future ci pipeline.

backup ci server (fail safe)

it may seem obvious, but i recommend setting up a backup process for jenkins configuration. script a jenkins job to use the thinbackup plugin or s3 plugin to send the jenkins configuration to an amazon s3 (cloud storage).

pipeline configuration

here are recommendations to consider:

  • set environment variables (i.e., hidden passwords, ssh keys, api keys, etc.)

  • security –create generic reusable jobs and naming conventions (i.e., jobs and environment variables)

  • keep jobs small –modulization and scalable infrastructure that allow for auto-scaling of slave nodes

discovery of plugins

be conservative with plugin usage. in my experience, plugins change all the time and become fragile. for the discovery mode of finding the right plugins for your ci infrastructure, i recommend evaluating if you can script the same functionality yourself rather than being dependent on third-party plugins. just minimize your plugin usage. having an upgrade process is important. don’t test upgrades on the live production ci server. set up a test environment to check all new plugins or new jenkins versions using existing jobs before applying a change to your production server.

configuration management tooling

i highly suggest using a configuration management tool to automate the process to achieve speed, scale, repeatability, and consistency. i recommend using scalr and chef tool solutions.

repositories

consider creating github webhooks for version control repositories. i recommend using artifactory (cloud storage) for ci artifacts.

the basics of setting up a jenkins master server

in this section of the guide, i will walk you through some steps to set up and manage jenkins.

discover, install and manage plugins

jenkins has hundreds of useful plugins. plugins will eliminate the need to create custom scripting to solve common problems with minimal pain. just remember plugins change often and become fragile. minimize your plugin usage if possible.

steps

  1. navigate to jenkins web interface > login as admin > manage jenkins > manage plugins > available (tab) .
  2. select the checkbox for all the plugins you want to install.
  3. select “download now and install after restart” at the bottom of the page.
  4. after jenkins finishes restarting, the installed plugins will appear under manage plugins > installed (tab) .

here are a few jenkins plugin recommendations:

  • git : allows you to integrate github to clone repository.
  • github pull request builder : builds pull requests in github and reports results.
  • swarm : enables slaves to auto-discover the nearby jenkins master and join it automatically.
  • sauce ondemand : allows you to integrate sauce labs selenium testing with jenkins.
  • pipeline : suite of plugins that lets you orchestrate automation, simple or complex.
  • slack : allows posting of build notifications to a slack channel.
  • thinbackup : simply backs up the global and job-specific configurations.

configure system settings

as an admin of jenkins, the configure system page is a critical configuration section. this page represents a variety of sections, each correlating to a different configuration area from generic jenkins settings and defining global environment variables. most installed plugins are configured on this page.

steps

  1. navigate to jenkins web interface > login as admin > manage jenkins > configure system .
  2. configure the root directory for workspace and build record.
  3. set the jenkins master executors to 0, setting up separate cloud instances to be the workers; jenkins master will only be the orchestrator.
  4. set environment variables (i.e. slack_token, sauce_api_key).
  5. configure the installed plugins (i.e. github, sauce labs, slack, etc.). this typically involves adding api keys or shared secrets.

configure global settings

straight out of the box, jenkins will allow anyone to run anything as a user of jenkins along with admin permissions, which is bad. i suggest enabling lightweight directory access protocol (ldap), wich allows you to use corporate service. users can log into jenkins with their usual company login credentials.

steps

  1. navigate to jenkins web interface > login as admin > manage jenkins > configure global security .
  2. select the checkbox to enable security.
  3. set tcp port for jnlp slave agents to 9000.
  4. select ldap from the access control (security realm) section and enter your ldap server address:
  5. select matrix-based security from the access control (authorization) section.
  6. select the checkbox for prevent cross site request forgery exploits, and enable slave –> master access control.

add node (slave)

there are multiple ways to add and configure a slave node farm. in all cases, a build, test, or deploy job are being run on a slave node. when it comes to creating multiple slave nodes, it is typically a straightforward process.

advanced – we create a farm on scalr with a jenkins master server and at least a handful of slave nodes for building and testing the application. we use the swarm plugin to enable slave nodes to auto-discover a nearby jenkins master and join it automatically. you can also manually run a curl command and add slave nodes to the jenkins master. it’s clear as mud, right? in layman terms, a slave node is a machine configured to clone the source code, compile, execute tests, or any tools needed. lastly, the build results are stored on the jenkins master, and artifacts should always end up in artifact storage (i.e. artifactory) not on the jenkins master.

steps

  1. check that the new node is online .
  2. navigate to jenkins web interface > login as admin > manage jenkins > manage nodes

jenkins is a very flexible application that involves a great deal of control for admins. it is easy to see when accessing the jenkins admin page that we have only scratched the surface but have laid a solid foundation to continue learning how to set up and manage jenkins.

go time! ready to create a ci pipeline

now that jenkins is configured, you are ready to orchestrate or maintain a ci pipeline. i recommend checking out the jenkins documentation getting started with pipeline to create and deploy your first ci pipeline.

jenkins9a
source: https://jenkins.io/images/pipeline/realworld-pipeline-flow.png

conclusion

the main motivation behind this article is to  identify the basic settings and recommended best practices for setting up jenkins master and slave architecture, then have the incentive and convenience to participate in ci architecture, along with enforcing discipline by assigning blame if the build, deployment, or test fails.

source: cloudbees

source: cloudbees

greg sypolt (@gregsypolt) is a senior engineer at gannett – usa today network and co-founder of quality element. he is a passionate automation engineer seeking to optimize software development quality while coaching team members on how to write great automation scripts and helping the testing community become better testers. greg has spent most of his career working on software quality—concentrating on web browsers, apis, and mobile. for the past 5+ years, he has focused on the creation and deployment of automated test strategies, frameworks, tools and platforms and continuous integration.

Jenkins (software)

Published at DZone with permission of , DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • The 5 Books You Absolutely Must Read as an Engineering Manager
  • How To Handle Secrets in Docker
  • Spring Boot vs Eclipse MicroProfile: Resident Set Size (RSS) and Time to First Request (TFR) Comparative
  • Reliability Is Slowing You Down

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: