Saturday, March 10, 2018


How to install Jenkins on centos 7 behind proxy

1. Set yum proxy
If you have newly created centos 7 machine, first enable proxy settings for yum,
To enable proxy for yum, open /etc/yum.conf, under [main] section, insert proxy settings as below,

2. Install Jenkins prerequisites
Jenkins server requires java. So before installing Jenkins server install latest java version. Check current java version, by executing java -version command. If older java found on system, uninstall it using
# yum remove java

After uninstallation, execute below command to install the latest version,
# yum install java-1.8.0-openjdk

Again verify the current java version using java -version when the installation gets completed
# java -version
openjdk version "1.8.0_161"
OpenJDK Runtime Environment (build 1.8.0_161-b14)
OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode)

3. Install Jenkins
In order install Jenkins, execute below commands,
# wget -O /etc/yum.repos.d/jenkins.repo   
# rpm -httpproxy http://<IPAddrOfProxyServer>:<proxyServerPort>/ --import
# yum install jenkins

4. Configuring firewall
Set rules to allow HTTP and port 8080, and reload firewall to take effect
# firewall-cmd --permanent --new-service=jenkins 
# firewall-cmd --permanent --service=jenkins --add-port=8080/tcp
# firewall-cmd --permanent --add-service=jenkins
# firewall-cmd --zone=public --add-service=http --permanent
# firewall-cmd --reload

5. Jenkins commands
Use below command to start Jenkins,
# systemctl start jenkins

to stop Jenkins,
# systemctl stop jenkins

and to check the current status of Jenkins process use,
# systemctl status jenkins

6. Once Jenkins server is up and running, launch Jenkins with http://<jenkinsMachineIP>:8080/ URL.

It will prompt 'Unlock Jenkins' screen. Get password from /var/lib/jenkins/secrets/initialAdminPassword file and enter it in 'Administrator Password' text box. Click on continue.

As you are working behind a proxy. It will show the message as Jenkins is offline.
To enable internet access, click on 'Configure Proxy' button, and fill proxy details. Setting up proxy will allow downloading plugins.

On 'Configure Proxy' page fill required information.
Server: <IPAddr_or_Hostname_OfProxyServer>
Port: <proxyServerPort>

If your proxy need authentication, enter username and passoword.
UserName: proxyServerUserName
Password: passwordOfProxyServerUser

If there is need to connect any host without going through the proxy, use 'No Proxy Host' field to specify these hosts, one host per line. You can specify hostname patterns also
No Proxy Host: *

Based on your need you can add plugins by using'Select plugins to install' option

Or if you are a beginner, try 'Install suggested plugins' option. It will install all necessary plugins

After plugin installation, you will be prompted to set admin user details which will be used for managing Jenkins

Once the admin user is created, select 'Start using Jenkins'

Now you are ready to create your first job

Note: Used 'root' user to perform all steps. If you don't have root access, use sudo user.

No comments:

Post a Comment