Jenkins
-
安装
-
安装Jdk环境
* 安装Jenkins
* 启动jenkins- 访问web页面
- 插件安装
- 常见错误
安装
确保防火墙及selinux是关闭状态
安装Jdk环境
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 1[root@jenkins tools]# rpm -ivh jdk-8u181-linux-x64.rpm
2warning: jdk-8u181-linux-x64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
3Preparing... ################################# [100%]
4Updating / installing...
5 1:jdk1.8-2000:1.8.0_181-fcs ################################# [100%]
6Unpacking JAR files...
7 tools.jar...
8 plugin.jar...
9 javaws.jar...
10 deploy.jar...
11 rt.jar...
12 jsse.jar...
13 charsets.jar...
14 localedata.jar...
15
16
17
测试java环境
1
2
3
4
5
6
7 1[root@jenkins tools]# java -version
2java version "1.8.0_181"
3Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
4Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
5
6
7
安装Jenkins
1
2
3
4
5
6
7
8
9 1[root@jenkins tools]# rpm -ivh jenkins-2.99-1.1.noarch.rpm
2warning: jenkins-2.99-1.1.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID d50582e6: NOKEY
3Preparing... ################################# [100%]
4Updating / installing...
5 1:jenkins-2.99-1.1 ################################# [100%]
6[root@jenkins tools]#
7
8
9
配置jenkins
1
2
3
4
5 1[root@jenkins tools]# vim /etc/sysconfig/jenkins
2修改为
3JENKINS_USER="root" #设置jenkins用户为root
4
5
启动jenkins
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 1[root@jenkins tools]# systemctl start jenkins
2[root@jenkins tools]# systemctl enable jenkins
3jenkins.service is not a native service, redirecting to /sbin/chkconfig.
4Executing /sbin/chkconfig jenkins on
5[root@jenkins tools]# systemctl is-enabled jenkins
6jenkins.service is not a native service, redirecting to /sbin/chkconfig.
7Executing /sbin/chkconfig jenkins --level=5
8enabled
9[root@jenkins tools]# systemctl status jenkins
10● jenkins.service - LSB: Jenkins Automation Server
11 Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)
12 Active: active (running) since Tue 2019-04-02 11:50:10 CST; 40s ago
13 Docs: man:systemd-sysv-generator(8)
14 CGroup: /system.slice/jenkins.service
15 └─2545 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/...
16
17Apr 02 11:50:06 jenkins systemd[1]: Starting LSB: Jenkins Automation Server...
18Apr 02 11:50:06 jenkins runuser[2529]: pam_unix(runuser:session): session opened for user root by (uid=0)
19Apr 02 11:50:10 jenkins jenkins[2524]: Starting Jenkins [ OK ]
20Apr 02 11:50:10 jenkins systemd[1]: Started LSB: Jenkins Automation Server.
21[root@jenkins tools]#
22
23
24
访问web页面
2. 查看密钥 并且粘贴到框内 点击继续
1
2
3
4
5 1[root@jenkins tools]# cat /var/lib/jenkins/secrets/initialAdminPassword
27ff6d79de6d04c0e906a7cb064ad725e
3
4
5
注: 如果此处一直白屏 可以拔掉网线 待正常后接通网络
3. 点击skip 跳过
4. 此处不进行设置 点击继续
5. 安装完成 点击开始 进入主页面
6. 进入主页后可以在右上角用户设置下修改默认密码
插件安装
插件目录 /var/lib/jenkins/plugins
将插件上传到插件目录
然后重启Jenkins即可
常见错误
Please make sure you have the correct access rights and the repository exists.
原因是Jenkins上的git配置个gitlab主机上配置一模一样 重新配置即可解决
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 1[root@jenkins monitor]# git config --global user.name "dev"
2[root@jenkins monitor]# git config --global user.email "dev@qq.com"
3[root@jenkins monitor]# git config --list
4user.name=dev
5user.email=dev@qq.com
6color.ui=true
7core.repositoryformatversion=0
8core.filemode=true
9core.bare=false
10core.logallrefupdates=true
11remote.origin.url=git@10.0.0.200:oldboy/monitor.git
12remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
13branch.master.remote=origin
14branch.master.merge=refs/heads/master
15[root@jenkins monitor]# history |tail -n5
16
17
18
19