Jenkins: 01 - Jenkins Deploy & Config (Centos7.dev)

Deploying Jenkins on CentOS7 ( jetty/winstone )

 

Install Folders

  • /var/lib/jenkins - filesystem
  • /usr/lib/jenkins - jenkins.war
  • /etc/init.d/jenkins - init & config

 

Finding Packages with Yum

sudo -c 'yum list wget'


Pull Jenkins Repo

  • Pull jenkins repo
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo

 

  • Get key for to validate the jenkins package
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

 


Install JDK8

cd /opt
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz"
tar xzf jdk-8u171-linux-x64.tar.gz
OR
tar -xvzf jdk-8u171-linux-x64.tar.gz

 

cd /opt/jdk1.8.0_171/
alternatives --install /usr/bin/java java /opt/jdk1.8.0_171/bin/java 2
alternatives --config java


There are 3 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*  1           /opt/jdk1.7.0_71/bin/java
 + 2           /opt/jdk1.8.0_45/bin/java
   3           /opt/jdk1.8.0_144/bin/java
   4           /opt/jdk1.8.0_171/bin/java

Enter to keep the current selection[+], or type selection number: 4

 


Installing Jenkins

sudo yum install jenkins

 

yum install jenkins
Loaded plugins: fastestmirror
You need to be root to perform this command.
[psqa@centos7dev ~]$ sudo yum install jenkins
[sudo] password for psqa:
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.mirror.lstn.net
 * epel: pubmirror1.math.uh.edu
 * extras: repo1.dal.innoscale.net
 * updates: mirror.dal10.us.leaseweb.net
 * webtatic: us-east.repo.webtatic.com
webtatic                                                                                                    | 3.6 kB  00:00:00     
Resolving Dependencies
--> Running transaction check
---> Package jenkins.noarch 0:2.121.1-1.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================================
 Package                       Arch                         Version                            Repository                     Size
===================================================================================================================================
Installing:
 jenkins                       noarch                       2.121.1-1.1                        jenkins                        71 M

Transaction Summary
===================================================================================================================================
Install  1 Package

Total download size: 71 M
Installed size: 71 M
Is this ok [y/d/N]: y
Downloading packages:
jenkins-2.121.1-1.1.noarch.rpm                                                                              |  71 MB  00:00:04     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : jenkins-2.121.1-1.1.noarch                                                                                      1/1
  Verifying  : jenkins-2.121.1-1.1.noarch                                                                                      1/1

Installed:
  jenkins.noarch 0:2.121.1-1.1                                                                                                     

Complete!

Enable firewall

firewall-cmd --permanent --add-port=8080/tcp
firewall-cmd --reload

Start Jenkins

[psqa@centos7dev ~]$ sudo systemctl start jenkins
[psqa@centos7dev ~]$ netstat -ntlp

http:<ip>:8080

Unlock Jenkins

To ensure Jenkins is securely set up by the administrator, a password has been written to the log (not sure where to find it?) and this file on the server:

/var/lib/jenkins/secrets/initialAdminPassword

 

Please copy the password from either location and paste it below.

Pull the code from the file

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

 


Linux

Debian/Ubuntu

On Debian-based distributions, such as Ubuntu, you can install Jenkins through apt.

Recent versions are available in an apt repository. Older but stable LTS versions are in this apt repository.

wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins

This package installation will:

  • Setup Jenkins as a daemon launched on start. See /etc/init.d/jenkins for more details.

  • Create a jenkins user to run this service.

  • Direct console log output to the file /var/log/jenkins/jenkins.log. Check this file if you are troubleshooting Jenkins.

  • Populate /etc/default/jenkins with configuration parameters for the launch, e.g JENKINS_HOME

  • Set Jenkins to listen on port 8080. Access this port with your browser to start configuration.

 

If your /etc/init.d/jenkins file fails to start Jenkins, edit the /etc/default/jenkins to replace the line ----HTTP_PORT=8080---- with ----HTTP_PORT=8081---- Here, "8081" was chosen but you can put another port available.

 


RedHat Linux RPM packages for Jenkins

To use this repository, run the following command:

sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

If you've previously imported the key from Jenkins, the "rpm --import" will fail because you already have a key. Please ignore that and move on.

You will need to explicitly install a Java runtime environment, because Oracle's Java RPMs are incorrect and fail to register as providing a java dependency. Thus, adding an explicit dependency requirement on Java would force installation of the OpenJDK JVM.

 

  • 2.54 (2017-04) and newer: Java 8
  • 1.612 (2015-05) and newer: Java 7

With that set up, the Jenkins package can be installed with:

yum install jenkins

See Wiki for more information, including how Jenkins is run and where the configuration is stored, etc.

Tags