DevOps Tools/CI/Jenkins/Configuration
(Created page with "Overview | Continuous Integration (CI) | Source Control Management (SCM) | [[DevOps_Tools/Containerization|C...") |
(→Installation) |
||
(5 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
− | [[DevOps_Tools/Overview|Overview]] | [[DevOps_Tools/CI|Continuous Integration (CI)]] | [[DevOps_Tools/SCM|Source Control Management (SCM)]] | [[DevOps_Tools/Containerization|Containerization]] | [[DevOps_Tools/Configuration|Configuration]] | + | [[DevOps_Tools/Overview|Overview]] | [[DevOps_Tools/CI|Continuous Integration (CI)]] | [[DevOps_Tools/SCM|Source Control Management (SCM)]] | [[DevOps_Tools/Containerization|Containerization]] | [[DevOps_Tools/Configuration|Configuration]] | [[DevOps_Tools/Integration|Integration]] |
=[[DevOps_Tools/CI/Jenkins/Configuration|Jenkins Configuration]]= | =[[DevOps_Tools/CI/Jenkins/Configuration|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: | ||
+ | <nowiki>~$ sudo cat /opt/jenkins/secrets/initialAdminPassword | ||
+ | 8dj28DH83d0DJ30h8d1uhd1skdfd</nowiki> | ||
+ | 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).<br> | ||
+ | '''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.<br> | ||
+ | Jenkins slave nodes have a few pre-requisites to install before you can use them. | ||
+ | <nowiki>~$ sudo yum install -y java-1.8.0-openjdk-devel git</nowiki> | ||
+ | Next, we need to create a new user so Jenkins can log in as that user. | ||
+ | <nowiki>~$ sudo useradd jenkins -d /home/jenkins -G wheel</nowiki> | ||
+ | |||
+ | ==Add/Configure Node== | ||
+ | Within Jenkins, you'll want to add the new node:<br> | ||
+ | Jenkins > [click] Manage Jenkins > [click] Manage Nodes > [click] New Node > [select] Permanent Agent > Define a Node Name<br> | ||
+ | Next we need to configure it. | ||
+ | ;Description | ||
+ | :define a description | ||
+ | ;# 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 '''<code>No Known Hosts file was found at /usr/share/tomcat/.ssh/known_hosts</code>'''.<br> | ||
+ | I had to make a few changes on the Jenkins Master: | ||
+ | <nowiki>~$ 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</nowiki> | ||
+ | Next we need to change Node configuration in Jenkins: | ||
+ | ;Host Key Verification Strategy | ||
+ | :Manually trusted key Verification Strategy | ||
+ | <br> | ||
+ | That should be it, you should now be able to successfully connect to you slave. |
Latest revision as of 13:51, 13 August 2020
Overview | Continuous Integration (CI) | Source Control Management (SCM) | Containerization | Configuration | Integration
Contents |
[edit] Jenkins Configuration
The goal of this page is to provide some examples of post-installation configurations.
[edit] 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.
[edit] 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.
[edit] Jenkins Slave Node
[edit] 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
[edit] 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
- 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.
[edit] 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.