Slide 1

Slide 1 text

Introduction to Jenkins Krishantha Dinesh Msc, MIEEE, MBCS Software Architect www.krishantha.com www.youtube.com/krish @krishantha

Slide 2

Slide 2 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Continues intergration • In Continuous Integration, the software is built and tested immediately followed by commit. With each commit code is built and tested. If the test is passed, build is tested for deployment. If deployment is a success, the code is pushed to production. This commit, build, test, and deploy is a continuous process and hence the name continuous integration/deployment.

Slide 3

Slide 3 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Following tools play major role on continues integration. • Continuous Integration Server (Jenkins, Bamboo, etc) • Source Control Tool (GIT, CVS, SVN, Mercurial, Perforce, ClearCase etc) • Build tool (Make, ANT, Maven, Ivy, Gradle etc) • Automation testing framework (Selenium, Appium, TestComplete, UFT etc)

Slide 4

Slide 4 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ What is Jenkins • Jenkins is an open source Continuous Integration server capable of orchestrating a chain of actions in CI process • Jenkins is entirely written in Java and it is a widely used application around the world that has around 300k installations and growing day by day. • It is a server-based application and requires a web server like Apache Tomcat. • The reason Jenkins became so popular is that of its monitoring of repeated tasks which arise during the development of a project. • By using Jenkins, software companies can accelerate their software development process, as Jenkins can automate build and test at a rapid rate. • Jenkins supports the complete development lifecycle of software from building, testing, documenting the software, deploying and other stages of a software development lifecycle.

Slide 5

Slide 5 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ History • Kohsuke Kawaguchi was tired of building the code and fixing errors repetitively. In 2004, created an automation server called Hudson that automates build and test task. • In 2011, Oracle who owned Sun Microsystems had a dispute with Hudson open source community, so the forked Hudson and renamed it as Jenkins. • Both Hudson and Jenkins continued to operate independently. But in short span of time, Jenkins acquired a lot of projects and contributors while Hudson remained with only 32 projects. With time, Jenkins became more popular, and Hudson is not maintained anymore.

Slide 6

Slide 6 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Overview

Slide 7

Slide 7 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Install Jenkins • Download Jenkins from https://jenkins.io/download/ • You can download distribution which matches to your operating system OR generic war file. Inorder to run war file you need java installed • You can run downloaded Jenkins as follows.

Slide 8

Slide 8 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Run jenkins • After execute it will show default admin password in log. Copy that and run http://localhost:8080 • Paste copied password on initial page

Slide 9

Slide 9 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Now you can install plugins

Slide 10

Slide 10 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Method 2: use as docker • docker pull jenkins/Jenkins:lts

Slide 11

Slide 11 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Run as docker • docker run -p 8080:8080 -p 50000:50000 --name jenkins -d jenkins/jenkins:lts Or • docker run -p 8080:8080 -p 50000:50000 --name jenkins -d -v jenkins_home:/var/jenkins_home jenkins/jenkins:lts To unlock log in to docker • docker exec -it jenkins bash Now can get the password cat /var/jenkins_home/secrets/initialAdminPassword

Slide 12

Slide 12 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ • After install the plugins create admin user

Slide 13

Slide 13 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Welcome to jenkins

Slide 14

Slide 14 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ security • Go to Manage Jenkins -> configure global security to configure authentication and authorizations

Slide 15

Slide 15 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Anonymous read • Once you enable anonymous read only access public users can come and check status without login

Slide 16

Slide 16 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Create build • We need sample project. You can have your own one or clone this https://github.com/krish/microservice-samples.git You need maven to run above example. So download maven if you do not have • Navigate to project folder • Manually test and package to make sure everything inline. • mvn test • mvn package

Slide 17

Slide 17 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Automate with jenkins • Create new job to automate the process (freestyle project)

Slide 18

Slide 18 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Configure git & build step

Slide 19

Slide 19 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Configure directory settings Either you need to have install maven locally OR if you use docker you need let Jenkins to install maven online. Either case you need to configure maven from global tool configuration and set that version here when you configure job.

Slide 20

Slide 20 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Build now You can click on job and see the progress

Slide 21

Slide 21 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ workspace • You can click on workspace and check what is happening inside Jenkins during build process

Slide 22

Slide 22 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Package application • Change compile to package before With package

Slide 23

Slide 23 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Archive • We may need to archive previous build before move in to next one. We can do this with post build steps Project view before and after configure archive

Slide 24

Slide 24 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Plugins • Plugins is the way any system use to give additional functionality • Jenkins also has various plugins to help to do what are the task you want to perform.

Slide 25

Slide 25 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Install blueocean plugin and switch to that. It will change standard UI after switch