Jenkins是一个开源软件项目,是基于Java开发的一种持续集成工具,用于监控持续重复的工作,旨在提供一个开
放易用的软件平台,使软件的持续集成变成可能。
官网:jenkins.io
官方安装文档:https://jenkins.io/doc/book/installing/
一、Jenkins安装
1.1、docker化安装jenkins
1)下载镜像
[root@jenkins ~]# docker pull jenkins/jenkins [root@jenkins ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE jenkins/jenkins latest 57f9f0b056cc 3 days ago 567MB
2)启动容器
#创建jenkins工作目录 [root@jenkins ~]# mkdir -p /var/jenkins_home [root@jenkins ~]# chown -R 1000 /var/jenkins_home #启动容器 [root@jenkins ~]# docker run -d -p 8080:8080 -p 50000:50000 -v /var/jenkins_home:/var/jenkins_home -v /etc/localtime:/etc/localtime --name jenkins jenkins/jenkins [root@jenkins ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e77fd29db990 jenkins/jenkins "/sbin/tini -- /usr/…" 10 seconds ago Up 8 seconds 0.0.0.0:8080->8080/tcp, 0.0.0.0:50000->50000/tcp jenkins 3694c2292ed0 gitlab/gitlab-ce "/assets/wrapper" 43 hours ago Up 2 hours (healthy) 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:222->22/tcp gitlab
3)在浏览器输入http://ip
:8080进入Jenkins登录页面。页面会提示你到服务器的指定位置获取初始化密码
[root@jenkins ~]# cat /var/jenkins_home/secrets/initialAdminPassword 0aa1d04474dd4d2fb07b1d9e4136e498
安装推荐的插件:插件安装时间较长,可能有的插件安装不成功,多试几次即可(也可以后续再安装)
创建管理员用户:
4)配置常用工具—jdk
1.2、进程式安装jenkins
1)安装jdk
[root@jenkins app]# rpm -ivh jdk-8u162-linux-x64.rpm [root@jenkins app]# java -version java version "1.8.0_162" Java(TM) SE Runtime Environment (build 1.8.0_162-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)
2)下载并安装jenkins rpm软件包
[root@jenkins app]# wget https://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat/jenkins-2.210-1.1.noarch.rpm [root@jenkins app]# rpm -ivh jenkins-2.210-1.1.noarch.rpm [root@jenkins app]# rpm -ql jenkins /etc/init.d/jenkins /etc/logrotate.d/jenkins /etc/sysconfig/jenkins /usr/lib/jenkins #jenkins安装目录 /usr/lib/jenkins/jenkins.war /usr/sbin/rcjenkins /var/cache/jenkins /var/lib/jenkins #默认的JENKINS_HOME /var/log/jenkins #日志文件
3)修改jenkins的启动用户
[root@jenkins app]# vim /etc/sysconfig/jenkins JENKINS_USER="root"
4)启动jenkins并访问http://ip:8080/
[root@jenkins app]# systemctl start jenkins [root@jenkins app]# systemctl enable jenkins
5)解锁jenkins
6)安装推荐插件
7)创建管理员账户
二、jenkins使用
2.1、创建自由风格项目
保存构建即可,第一次会从maven中央仓库下载依赖,时间较长,多试几次