Giter Site home page Giter Site logo

jenkins-hello-world's Introduction

Jenkins-Hello-World

Pre-requisites

You should know Docker, basic CI-CD concept & basics of what Jenkins is used for

You should have Linux OS like Ubuntu, Java (OpenJDK 11) & Docker installed

Description

This project was created to install Jenkins on a local machine (Ubuntu 16.04) and create a basic pipeline with GitHub & Docker

We will be doing is

  • Installing Jenkins and running it, on a local machine
  • Creating a docker image
  • Pushing it to docker hub using Jenkins' pipeline

Installing Jenkins

  1. Add repository keystream
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -

You must get a response printed as OK

  1. Now add the Debian package to your sources.list
sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
  1. Now, update system
sudo apt update
  1. Finally, install Jenkins
sudo apt install jenkins

Now, Jenkins is installed in your system and is ready to run.

Start, stop, status of Jenkins service

We would be using standard systemctl commands

  • To start
sudo systemctl start jenkins
  • To check status
sudo systemctl status jenkins
  • To stop
sudo systemctl stop jenkins
  • To start on boot
sudo systemctl enable jenkins

First time login

  1. Go to <IP_ADDRESS>:8080

  2. Jenkins login page should appear asking you to enter the administrator password

  3. Now open a terminal and type

sudo cat /var/lib/jenkins/secrets/initialAdminPassword

A string printed on the console is the administrator password, enter this is on Jenkins login page

  1. Choose Install selected plugins (You may choose Select plugins to install)
    Now it will install plugins and show you the details, it takes some time

  2. It would ask you to create a new 'Admin User'.

Now, Jenkins is configured for the system

Integrating GitHub with Jenkins

  1. Go to Manage Jenkins from menu on the left pane

  2. Click on Manage Plugins

  3. Go to Advance tab

  4. Search & install GitHub Integration, Pipeline, Docker & Docker Pipeline plugins

    a. Click on Download now and install after restart

    b. On the next window select the checkbox for Restart Jenkins when installation is complete and no jobs are running at the bottom of the page. Jenkins will restart once plugin is downloaded

  5. Now go to your GitHub repository, go to Settings, go to Webhooks, click on Add Webhook

  6. For the payload URL, provide your Jenkins URL and the GitHub webhook path at the end of the URL - https://<JENKINS_URL>/github-webhook/.

  7. Content type should be JSON

  8. In Which events would you like to trigger this webhook? select Just the push event.

Now we are ready to integrate any GitHub repository with Jenkins

Creating Pipeline

  1. On the dashboard, click on Create Job option

  2. Give name to your pipeline

  3. Choose Pipeline

  4. In Build Triggers select GitHub hook trigger for GITScm polling

  5. In Pipeline section choose definition as Pipeline script from SCM

  6. In the Source Code Management (SCM) tab, select Git enter GitHub repository URL, and save

  7. Now copy Jenkinsfile in your repository base path

  8. Add Docker credentials to Jenkins host

    a. On the top right of home page, click on dropdown next to the username

    b. Select Credentials

    c. Go to System OR Click on Global from any one pre-existing credentials

    d. Click on Add Credentials

    e. Keep scope Global

    f. Enter Docker Hub username & password and set some ID in ID field

  9. Now in the Jenkinsfile in the environment set the ID

The pipeline is now created, push code to GitHub to see the pipeline run

jenkins-hello-world's People

Contributors

varungujarathi9 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.