Jenkins安装

Jenkins

    • 安装
      • 安装Jdk环境
      • 安装Jenkins
      • 启动jenkins
    • 访问web页面
    • 插件安装
    • 常见错误

安装

确保防火墙及selinux是关闭状态

安装Jdk环境

[root@jenkins tools]# rpm -ivh jdk-8u181-linux-x64.rpm 
warning: jdk-8u181-linux-x64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:jdk1.8-2000:1.8.0_181-fcs        ################################# [100%]
Unpacking JAR files...
	tools.jar...
	plugin.jar...
	javaws.jar...
	deploy.jar...
	rt.jar...
	jsse.jar...
	charsets.jar...
	localedata.jar...

测试java环境

[root@jenkins tools]# java -version
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

安装Jenkins

[root@jenkins tools]# rpm -ivh jenkins-2.99-1.1.noarch.rpm 
warning: jenkins-2.99-1.1.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID d50582e6: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:jenkins-2.99-1.1                 ################################# [100%]
[root@jenkins tools]# 

配置jenkins

[root@jenkins tools]# vim /etc/sysconfig/jenkins
修改为
JENKINS_USER="root" #设置jenkins用户为root

启动jenkins

[root@jenkins tools]# systemctl start jenkins
[root@jenkins tools]# systemctl enable jenkins
jenkins.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig jenkins on
[root@jenkins tools]# systemctl is-enabled jenkins
jenkins.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig jenkins --level=5
enabled
[root@jenkins tools]# systemctl status jenkins
● jenkins.service - LSB: Jenkins Automation Server
   Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)
   Active: active (running) since Tue 2019-04-02 11:50:10 CST; 40s ago
     Docs: man:systemd-sysv-generator(8)
   CGroup: /system.slice/jenkins.service
           └─2545 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/...

Apr 02 11:50:06 jenkins systemd[1]: Starting LSB: Jenkins Automation Server...
Apr 02 11:50:06 jenkins runuser[2529]: pam_unix(runuser:session): session opened for user root by (uid=0)
Apr 02 11:50:10 jenkins jenkins[2524]: Starting Jenkins [  OK  ]
Apr 02 11:50:10 jenkins systemd[1]: Started LSB: Jenkins Automation Server.
[root@jenkins tools]# 

访问web页面

  1. http://10.0.0.201:8080/

Jenkins安装_第1张图片
2. 查看密钥 并且粘贴到框内 点击继续

[root@jenkins tools]# cat /var/lib/jenkins/secrets/initialAdminPassword
7ff6d79de6d04c0e906a7cb064ad725e

注: 如果此处一直白屏 可以拔掉网线 待正常后接通网络
Jenkins安装_第2张图片
3. 点击skip 跳过Jenkins安装_第3张图片
4. 此处不进行设置 点击继续Jenkins安装_第4张图片
5. 安装完成 点击开始 进入主页面Jenkins安装_第5张图片
6. 进入主页后可以在右上角用户设置下修改默认密码Jenkins安装_第6张图片

插件安装

插件目录 /var/lib/jenkins/plugins

将插件上传到插件目录
然后重启Jenkins即可

常见错误

Please make sure you have the correct access rights and the repository exists.
原因是Jenkins上的git配置个gitlab主机上配置一模一样 重新配置即可解决

[root@jenkins monitor]# git config --global user.name "dev"
[root@jenkins monitor]# git config --global user.email "[email protected]"
[root@jenkins monitor]# git config  --list
user.name=dev
[email protected]
color.ui=true
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
[email protected]:oldboy/monitor.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
[root@jenkins monitor]# history |tail -n5


你可能感兴趣的:(服务部署)