配置yum源安装jenkins
安装命令:
wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
yum install jenkins
vi /etc/sysconfig/jenkins
注意启动前在/etc/sysconfig/jenkins修改端口号和JENKINS_HOME
修改端口号,默认是8080端口,这里我修改为8081
JENKINS_HOME="/home/Sudley/Jenkins"
安装记录如下:
[root@bogon /home/Sudley/Jenkins]#lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-ia32:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-ia32:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-ia32:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-ia32:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-ia32:printing-4.1-noarch
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 7.2 (Maipo)*.5
Release: 7.2
Codename: Maipo
[root@bogon /home/Sudley/Jenkins]
[root@bogon /home/Sudley/Jenkins]#wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
--2019-12-14 07:02:50-- http://pkg.jenkins-ci.org/redhat/jenkins.repo
Resolving pkg.jenkins-ci.org (pkg.jenkins-ci.org)... 52.202.51.185
Connecting to pkg.jenkins-ci.org (pkg.jenkins-ci.org)|52.202.51.185|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 71
Saving to: ‘/etc/yum.repos.d/jenkins.repo’
100%[===================================================>] 71 --.-K/s in 0s
2019-12-14 07:02:51 (9.80 MB/s) - ‘/etc/yum.repos.d/jenkins.repo’ saved [71/71]
[root@bogon /home/Sudley/Jenkins]#rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
[root@bogon /home/Sudley/Jenkins]#yum install jenkins
Loaded plugins: aliases, changelog, kabi, langpacks, ovl, product-id, search-disabled-repos,
: subscription-manager, tmprepo, verify, versionlock
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Loading support for Red Hat kernel ABI
Resolving Dependencies
--> Running transaction check
---> Package jenkins.noarch 0:2.208-1.1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================
Package Arch Version Repository Size
=============================================================================================
Installing:
jenkins noarch 2.208-1.1 jenkins 60 M
Transaction Summary
=============================================================================================
Install 1 Package
Total download size: 60 M
Installed size: 60 M
Is this ok [y/d/N]: y
...
Installing : jenkins-2.208-1.1.noarch 1/1
Verifying : jenkins-2.208-1.1.noarch 1/1
Installed:
jenkins.noarch 0:2.208-1.1
Complete!
[root@bogon /home/Sudley/Jenkins]#vi /etc/sysconfig/jenkins
[root@bogon /home/Sudley/Jenkins]#service jenkins restart
Restarting jenkins (via systemctl): [ OK ]
[root@bogon /home/Sudley/Jenkins]#
启动成功后登陆jenkins,在这里我使用的是windows的浏览器登陆jenkins,登陆地址如下
http://192.168.37.133:8081/
如果是使用本机登陆也可以用http://localhost:8081/登录
按照提示激活jenkins
[root@bogon /home/Sudley/Jenkins]#cat /var/lib/jenkins/secrets/initialAdminPassword
47bed804e5e94629be4c0779ab352c4f
安装插件,如果是用于自己调试的建议安装默认插件就行,如果是专业级的知道自己需要哪些插件也可以自定义安装,
安装好后需要另外添加插件可参考
Jenkins安装plugin
插件安装完成后一直按照推荐配置配置到最后
创建管理员账户并登陆
创建一个测试任务,执行任务并查看执行日志
下载tomcat
tomcat官方下载链接:https://tomcat.apache.org/
下载Jenkins包
war 包下载地址 https://jenkins.io/download/
环境配置
提前安装好Java 8,在 /etc/profile 文件(或其他配置文件)中配置好环境变量 JAVA_HOME
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64/
JENKINS_HOME=/home/.jenkins
JAVA_BIN=${JAVA_HOME}/bin/
export PATH=${JAVA_BIN}:${JAVA_JRE}:${PATH}
服务安装
解压tomcat包,本领在home目录演示
tar -xf apache-tomcat-10.0.0-M1.tar.gz
将jenkins.war包拷贝到/home/apache-tomcat-10.0.0-M1/webapps目录
port号默认是8080,这里将其修改为8082
bin目录执行sh startup.sh启动tomcat
访问 http://192.168.37.134:8082/jenkins登录并配置jenkins步骤如第一节