Jenkins Installation Guide with Blue Ocean Setup and Github Integration

in #devops5 years ago

Jenkins is a great tool used to setup continuous integration and continuous deployment environments, Jenkins automation allows you to can create jobs to build, test, and deploy your applications.

Image of Jenkins

To get Jenkins running on your machine you will need to create a container using docker.

Assuming you have docker installed run the command:

docker run --name jenkinsci -p 8080:8080 jenkins/jenkins:lts

Docker will execute the command and run Jenkins on your machine.

Make sure to grab the admin key from the terminal

docker jenkins
Don’t share passwords 😉

Navigate to http://localhost:8080. You’ll see the “Getting Started” Jenkins page:

Jenkins

Enter the administrator password and press continue.

On the following screen click “Install suggested plugins”

Plugins will begin to install:

plugins

After the installation completes, create a user or continue as Admin.

You will be asked to set your Jenkins URL:

Once complete you can start using Jenkins.

Now let’s install some plugins.

In order to install the plugins you need, click on “Manage Jenkins” on the left hand side:

You will see “Manage Plugins” button:

On the “Installed” tab, you will see all of the default plugins that were installed.

Sometimes when you go to install a plugin it will fail, this can happen when a plugin has a missing dependency. If this happens, head over to the Jenkins plugin library and find the required plugins

Click on the “Available” tab and then search for "Blue Ocean" in the filter:

plugin search

Click the checkbox for blue ocean then press the “Download now and install after restart” button

You will see a “Open Blue Ocean” tab once you restart and login to Jenkins:

So at this point Jenkins is installed with the blue ocean plugin, now we need to connect Jenkins to your Github Repository so it can trigger on a new build.

You can provide Github with Jenkins access through SSH by generating a key, but Blue Ocean makes this easier by allowing Jenkins to access Github via webhooks.

In Blue Ocean Click “New Pipeline”

Choose Github as your store, pick an organization, and repository

Click “Create Pipleline” and Jenkins will go to work

As the pipeline is being created, lets head over to Github and setup our webhook

In the settings of your repo you will need to add the payload URL for Jenkins Github webhook

//Add the ip and port for your Jenkins instance with /github-webhook 
http://ipAddress:port/github-webhook/

Hit save webhook and you are good to go!

From here you will need to decide when you want Jenkins to trigger the pipeline based on branch PRs. The steps Jenkins will take in order to fulfill your automation needs depends on your Jenkinsfile script. You can learn more about that here

I hope this guide helped, I’d enjoy hearing about your experience in the comments below.

Coin Marketplace

STEEM 0.17
TRX 0.13
JST 0.028
BTC 56681.24
ETH 3016.79
USDT 1.00
SBD 2.28