DevOps Tools/CI/Jenkins/Configuration

From r00tedvw.com wiki
Revision as of 14:51, 13 August 2020 by R00t (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Overview | Continuous Integration (CI) | Source Control Management (SCM) | Containerization | Configuration | Integration

Contents

Jenkins Configuration

The goal of this page is to provide some examples of post-installation configurations.

Post-Installation

Immediately after finishing installation of Jenkins and restarting Tomcat, when you browse to the page, you'll be greeted with a page asking for an administrator secret code. You can obtain this code easily:

~$ sudo cat /opt/jenkins/secrets/initialAdminPassword
8dj28DH83d0DJ30h8d1uhd1skdfd

Jenkins will then ask you if you want to install some common plug-ins from a pre-defined list, which i've always done, or manually select what you want (or don't want).
Note: I would recommend that you install at least (1) plug-in to make sure Jenkins can successfully write to the directories it needs and create files/make changes. Better to find out now than later on.

Common Additional Plugins

Below are some common plugins which i've installed.

Gitlab Authentication plugin
This is the an authentication plugin using gitlab OAuth.
Gitlab Hook Plugin
Enables Gitlab web hooks to be used to trigger SMC polling on Gitlab projects
GitLab Logo Plugin
Display GitLab Repository Icon on dashboard
GitLab Plugin
This plugin allows GitLab to trigger Jenkins builds and display their results in the GitLab UI.
Safe Restart Plugin
This plugin allows you to restart Jenkins safely.

Jenkins Slave Node

Installation

NOTE: These instructions assume you are running Jenkins on Tomcat.
Jenkins slave nodes have a few pre-requisites to install before you can use them.

~$ sudo yum install -y java-1.8.0-openjdk-devel git

Next, we need to create a new user so Jenkins can log in as that user.

~$ sudo useradd jenkins -d /home/jenkins -G wheel

Add/Configure Node

Within Jenkins, you'll want to add the new node:
Jenkins > [click] Manage Jenkins > [click] Manage Nodes > [click] New Node > [select] Permanent Agent > Define a Node Name
Next we need to configure it.

Description
define a description
  1. of executors
these will vary depending on the slave resources and jobs assigned.
Remote root directory
I opted to use the home directory of the user I created. /home/jenkins
Labels
Think of these as group assignments. Generally they should match either the operating system or jobs. Since nodes can have different dependencies installed, not all may be able to complete all jobs.
Usage
you can either let the Jenkins master use this node as much as possible, or only with build jobs that have a matching label.
Launch method
via ssh, via execution from the master, or via a windows service.

The rest should be self explanatory.

Troubleshooting

After I created the node, the Jenkins Master was unable to connect citing No Known Hosts file was found at /usr/share/tomcat/.ssh/known_hosts.
I had to make a few changes on the Jenkins Master:

~$ sudo ln -s /home/jenkins/.ssh /usr/share/tomcat/.ssh
~$ sudo chown -h root:tomcat /usr/share/tomcat/.ssh
~$ sudo chown -R jenkins:tomcat /home/jenkins
~$ sudo chmod -R 770 /home/jenkins
~$ sudo chmod 664 /home/jenkins/.ssh/known_hosts
~$ sudo ssh-keyscan -H jenkins-slave01.r00tedvw.com | sudo tee -a /usr/share/tomcat/.ssh/known_hosts

Next we need to change Node configuration in Jenkins:

Host Key Verification Strategy
Manually trusted key Verification Strategy


That should be it, you should now be able to successfully connect to you slave.

Personal tools
Namespaces

Variants
Actions
Navigation
Mediawiki
Confluence
DevOps Tools
Ubuntu
Ubuntu 22
Mac OSX
Oracle Linux
AWS
Windows
OpenVPN
Grafana
InfluxDB2
TrueNas
OwnCloud
Pivotal
osTicket
OTRS
phpBB
WordPress
VmWare ESXI 5.1
Crypto currencies
HTML
CSS
Python
Java Script
PHP
Raspberry Pi
Canvas LMS
Kaltura Media Server
Plex Media Server
MetaSploit
Zoneminder
ShinobiCE
Photoshop CS2
Fortinet
Uploaded
Certifications
General Info
Games
Meal Plans
NC Statutes
2020 Election
Volkswagen
Covid
NCDMV
Toolbox