How to Install Jenkins on CentOS 7

Jenkins is a free and open source CI (Continuous Integration) tool which is written in JAVA. Jenkins is widely used for project development, deployment, and automation. Jenkins allows you to automate the non-human part of the whole software development process. It supports version control tools, including AccuRev, CVS, Subversion, Git, Mercurial, Perforce, ClearCase and RTC, and can execute Apache Ant, Apache Maven and sbt based projects as well as arbitrary shell scripts and Windows batch commands. The creator of Jenkins is Kohsuke Kawaguchi.[3] Released under the MIT License.

Jenkins' security depends on two factors: 1. access control 2. protection from external threats.

Access control can be customized via two ways, user authentication and authorization.

Protection from external threats such as CSRF attacks and malicious builds is supported as well.

Requirements

It does not require any special kind of hardware, you'll only need a CentOS 7 server and a root user access over it. You can switch from non root user to root user usingsudo -icommand.

Update System

It is highly recommended to install Jenkins on a freshly updated server. To upgrade available packages and system run below given command and it'll do the job for you.

yum -y update

Install Java

Before going through the installation process of Jenkins you'll need to set up Java Virtual Machine or JDK to your system. Simply run following command to install Java.

yum -y install java-1.8.0-openjdk.x86_64

Once installation is finished you can check the version to confirm the installation, to do run following command.

java -version

The above command will tell you about the installation details of java. By running the above command you should see the following result on your terminal screen.

openjdk version"1.8.0_131"OpenJDK Runtime Environment(build 1.8.0_131-b12)OpenJDK 64-Bit Server VM(build 25.131-b12, mixed mode)

Next, you'll need to setup two environment variablesJAVA_HOMEandJRE_HOMEand to do so run following commands one by one.

cp /etc/profile /etc/profile_backupecho 'export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk' | sudo tee -a /etc/profileecho 'export JRE_HOME=/usr/lib/jvm/jre' | sudo tee -a /etc/profilesource /etc/profile

Finally print them for review using following commands.

echo $JAVA_HOME

You should see following output.

/usr/lib/jvm/jre-1.8.0-openjdk

echo $JRE_HOME

Install Jenkins

We have installed all the dependencies required by Jenkins and now we are ready to install Jenkins. Run following commands to install latest stable release of Jenkins.

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

The above two commands will add the jenkins repository and also import the key. If in case you have previously imported the key from Jenkins then therpm --importwill fail because you already have a key. Please ignore that and move on.

Now run following command to install Jenkins on your server.

yum -y install jenkins

Next, you'll need to start Jenkins services and set it to run at boot time and to do so use following commands.

systemctl start jenkins.servicesystemctl enable jenkins.service

Jenkins runs on port 8080 so you'll need to change firewall rules to allow traffic on port 8080.

If in case you don't have firewalld services installed on your server then you can install it usingyum -y install firewalldand you can start it usingsystemctl start firewalld

Next run these below given command to modify the firewalld rules.

firewall-cmd --zone=public --permanent --add-port=8080/tcpfirewall-cmd --reload

Web Access

Open up your favorite web browser and please visit http://YourServerIPaddress:8080 and finish the installation wizard.

You'll see a webpage like this which will ask you for a password and this admin password is created and stored in the log file/var/log/jenkins/jenkins.log.

Run the below command to get the password.

grep -A 5 password /var/log/jenkins/jenkins.log

Copy the password and paste it in above windows and click onContinuebutton.

Next, you'll see a setup wizard web page like this and Select the option :Install suggested plugins. It will install required plugins for Jenkins.

Next, it will ask you to create an Admin User so provide your username and password and email address and then finally click onSave and Finishbutton.

On the next page click onStart using Jenkinsbutton and you'll see a Jenkins user dashboard.

Install Nginx

You can install nginx as reverse proxy for Jenkins, so visitors will no longer need to key in the port number 8080 when accessing your Jenkins application. run following command to install nginx.

yum -y install nginx

Next, you'll need to edit the configuration details using any text editor here we are using nano text editor. you can also install it usingyum -y install nano

nano /etc/nginx/nginx.conf

Find these lines in the configuration file:

location /{}

Add following content into the { } segment in configuration file then save the file and exit from the text editor.

proxy_pass http://127.0.0.1:8080;proxy_redirect off;proxy_set_header Host$host;proxy_set_header X-Real-IP$remote_addr;proxy_set_header X-Forwarded-For$proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto$scheme;

Next, start the nginx services and enable it to run at boot time like we have done before for Jenkins services using following commands.

systemctl start nginx.servicesystemctl enable nginx.service

Finally you'll need to modify firewall rules using following commands.

firewall-cmd --zone=public --permanent --add-service=httpfirewall-cmd --reload

Now you can access it through a web browser via http://yourServerIP .

Conclusion

In tutorial you learned to how to install and configure Jenkins on your CentOS 7 server. You also learned to install nginx and setting it up with Jenkins. We hope now you have enough knowledge to work with Jenkins.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子玉凯,更是在濱河造成了極大的恐慌,老刑警劉巖娘汞,帶你破解...
    沈念sama閱讀 212,222評(píng)論 6 493
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異夕玩,居然都是意外死亡你弦,警方通過(guò)查閱死者的電腦和手機(jī)惊豺,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,455評(píng)論 3 385
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)禽作,“玉大人尸昧,你說(shuō)我怎么就攤上這事】醭ィ” “怎么了烹俗?”我有些...
    開(kāi)封第一講書人閱讀 157,720評(píng)論 0 348
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)萍程。 經(jīng)常有香客問(wèn)我幢妄,道長(zhǎng),這世上最難降的妖魔是什么茫负? 我笑而不...
    開(kāi)封第一講書人閱讀 56,568評(píng)論 1 284
  • 正文 為了忘掉前任磁浇,我火速辦了婚禮,結(jié)果婚禮上朽褪,老公的妹妹穿的比我還像新娘。我一直安慰自己无虚,他們只是感情好缔赠,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,696評(píng)論 6 386
  • 文/花漫 我一把揭開(kāi)白布。 她就那樣靜靜地躺著友题,像睡著了一般嗤堰。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上度宦,一...
    開(kāi)封第一講書人閱讀 49,879評(píng)論 1 290
  • 那天踢匣,我揣著相機(jī)與錄音,去河邊找鬼戈抄。 笑死离唬,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的划鸽。 我是一名探鬼主播输莺,決...
    沈念sama閱讀 39,028評(píng)論 3 409
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼裸诽!你這毒婦竟也來(lái)了嫂用?” 一聲冷哼從身側(cè)響起,我...
    開(kāi)封第一講書人閱讀 37,773評(píng)論 0 268
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤丈冬,失蹤者是張志新(化名)和其女友劉穎嘱函,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體埂蕊,經(jīng)...
    沈念sama閱讀 44,220評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡往弓,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,550評(píng)論 2 327
  • 正文 我和宋清朗相戀三年疏唾,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片亮航。...
    茶點(diǎn)故事閱讀 38,697評(píng)論 1 341
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡荸实,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出缴淋,到底是詐尸還是另有隱情准给,我是刑警寧澤,帶...
    沈念sama閱讀 34,360評(píng)論 4 332
  • 正文 年R本政府宣布重抖,位于F島的核電站露氮,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏钟沛。R本人自食惡果不足惜畔规,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 40,002評(píng)論 3 315
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望恨统。 院中可真熱鬧叁扫,春花似錦、人聲如沸畜埋。這莊子的主人今日做“春日...
    開(kāi)封第一講書人閱讀 30,782評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)悠鞍。三九已至对室,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間咖祭,已是汗流浹背掩宜。 一陣腳步聲響...
    開(kāi)封第一講書人閱讀 32,010評(píng)論 1 266
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留么翰,地道東北人牺汤。 一個(gè)月前我還...
    沈念sama閱讀 46,433評(píng)論 2 360
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像硬鞍,于是被迫代替她去往敵國(guó)和親慧瘤。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,587評(píng)論 2 350

推薦閱讀更多精彩內(nèi)容