【Jenkins系列二】、jenkins安装部署

今天刚好有个测试环境需要我来部署一下,就写了一下操作手册,用做分享

服务器操作系统:centos7.5

jenkins版本:2.150

 

 

1、jenkins下载

地址:https://pkg.jenkins.io/redhat-stable/

或直接使用命令 wget https://pkg.jenkins.io/redhat-stable/jenkins-2.150.1-1.1.noarch.rpm

2、配置环境

java环境(请参考https://blog.csdn.net/wu2700222/article/details/83833217)

vim /etc/profile

export JAVA_HOME=/usr/local/jdk1.8.0_191
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib/dt.JAVA_HOME/lib/tools.jar:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:${PATH}

在/usr/bin目录中创建一个java软链接

ln -s /opt/soft/jdk1.8.0_181/bin/java    /usr/bin/java

maven环境

下载地址:wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz


 

tar -zxvf apache-maven-3.3.9-bin.tar.gz

mv apache-maven-3.3.9 /usr/local/apache-maven

ls /usr/local/apache-maven

   (注意:要放到/usr/local中不然jenkins会没有权限一直报is not a directory on the Jenkins master错误)

设置环境变量,打开etc/profile

export JAVA_HOME=/usr/local/jdk1.8.0_191
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export MAVEN_HOME=/usr/local/apache-maven
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$MAVEN_HOME/bin:$PATH

再执行

source /etc/profile

 

[root@i-tf86mb8v usr]# mvn -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
Maven home: /usr/local/apache-maven
Java version: 1.8.0_191, vendor: Oracle Corporation
Java home: /usr/local/jdk1.8.0_191/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-862.el7.x86_64", arch: "amd64", family: "unix"

 

3、安装jenkins

[root@i-tf86mb8v soft]# pwd
/data/soft
[root@i-tf86mb8v soft]# ls
blm_kong                        kong-community-edition-0.10.4.el7.noarch.rpm  lua-resty-rsa                           redis-3.2.12
jenkins-2.150.1-1.1.noarch.rpm  lua-cjson                                     rabbitmq-server-3.6.6-1.el7.noarch.rpm  redis-3.2.12.tar.gz
[root@i-tf86mb8v soft]# 
[root@i-tf86mb8v soft]# yum install jenkins-2.150.1-1.1.noarch.rpm -y

yum装好后通过查询发现启动失败(Starting Jenkins bash: /usr/bin/java: No such file or directory)

通过建立软链接解决,成功启动

[root@i-tf86mb8v soft]# ln -s /usr/local/jdk1.8.0_191/bin/java /usr/bin/java
[root@i-tf86mb8v soft]# service jenkins start                               
Starting jenkins (via systemctl):                          [  OK  ]
[root@i-tf86mb8v soft]# systemctl status jenkins.service                    
● jenkins.service - LSB: Jenkins Automation Server
   Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)
   Active: active (running) since Wed 2018-12-26 10:38:02 CST; 5s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 16592 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS)
    Tasks: 31
   Memory: 344.9M
   CGroup: /system.slice/jenkins.service
           └─16613 /usr/bin/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/jenkins.war --lo...

Dec 26 10:38:01 i-tf86mb8v systemd[1]: Starting LSB: Jenkins Automation Server...
Dec 26 10:38:01 i-tf86mb8v runuser[16597]: pam_unix(runuser:session): session opened for user jenkins by (uid=0)
Dec 26 10:38:02 i-tf86mb8v runuser[16597]: pam_unix(runuser:session): session closed for user jenkins
Dec 26 10:38:02 i-tf86mb8v systemd[1]: Started LSB: Jenkins Automation Server.
Dec 26 10:38:02 i-tf86mb8v jenkins[16592]: Starting Jenkins [  OK  ]
[root@i-tf86mb8v soft]# 

增加至开机自启

[root@i-tf86mb8v soft]# chkconfig jenkins on

4、配置jenkins的web

浏览器输入 http://172.17.0.2:8080/ 回车

上面提示需要输入初始登录密码,密钥在/var/lib/jenkins/secrets/initialAdminPassword ,我们登录服务器查看密钥

[root@i-tf86mb8v soft]# cat /var/lib/jenkins/secrets/initialAdminPassword
4e082b03a7df428bb164f5561cd8f5d4

输入4e082b03a7df428bb164f5561cd8f5d4 点击Continue,安装标准插件

安装的界面

自动进入创建用户界面

填写内容后点击save and continue

安装完毕

进入全局工具配置配置jdk

配置maven (打包java项目中会使用到)

 

ok,导致,jenkins的初步配置就已完成,后续如果有空我会在该系列中补充java项目、nodejs项目、python项目的jenkins配置

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值