最近项目上开始实行自动化测试,避免不了与jenkins等持续集成工具打交道,今天就给大家分享一下有关jenkins的简单安装和使用

1,准备环境

(1)ubuntu系统

(2)docker

(3)jenkins

2,安装docker

(1)安装 sudo apt-get install -y docker.io

(2)启动docker  systemctl start docker   可以设置永久开机自启动  systemctl enable docker

(3)docker version 或 docker -v 可以查看版本,说明docker安装成功了

(4)安装完成后,当你执行docker run hello-world,你可以发现docker先从本地找hello-world镜像,没有的话,就从官方仓库找

docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world

(5)在仓库中搜索镜像,比如搜索ubuntu镜像,docker search ubuntu 找到之后(并不一定有,所以可能需要换仓库),进行拉取镜像docker pull ubuntu

有的镜像很大,仓库又在国外,速度很慢。我们可以自己搭建私服,也可以用一些其他地址。

目前世界上最大最知名的公共仓库是Docker官方的Docker Hub,国内比较知名的有:Docker Pool、阿里云仓库等

(6)阿里云仓库镜像服务配置,首先在阿里云https://www.aliyun.com/上注册账户,登录之后,进入控制台-选择docker容器镜像服务-进入镜像加速器-按照上面说的方法在ubuntu上配置即可;

配置完成执行docker info | grep http就可以看到刚才配置的仓库地址了

关于docker的具体使用方法,不在此赘述,可以参考

菜鸟教程https://www.runoob.com/docker/docker-tutorial.html

官方英文文档https://docs.docker.com/

中文文档http://www.dockerinfo.net/document

3,安装jenkins

相关参考

https://jenkins.io/zh/doc/book/installing/

https://hub.docker.com/r/jenkins/jenkins

(1)准备本地文件,用来保存重要内容,以防容器被意外破坏和删除

mkdir /usr/local/workspace/jenkins;chmod 777 jenkins

(2)执行docker pull和docker run命令,启动容器,这个命令如果本地没有镜像,会自动的从仓库拉取

docker pull jenkins/jenkins:lts
lts: Pulling from jenkins/jenkins
9cc2ad81d40d: Pull complete
e6cb98e32a52: Pull complete
ae1b8d879bad: Pull complete
42cfa3699b05: Pull complete
8d27062ef0ea: Pull complete
9b91647396e3: Pull complete
7498c1055ea3: Pull complete
7649b1010bf2: Pull complete
1c3f5e14c681: Pull complete
a204aa63f757: Pull complete
9b57f731dd16: Pull complete
d21f82c5429a: Pull complete
440e5fb06ea6: Pull complete
5d43ca048df2: Pull complete
1421ef7f2b0c: Pull complete
0c2b6150f92f: Pull complete
9e0d2e7a610a: Pull complete
36bd756f5339: Pull complete
e27e28c0b503: Pull complete
Digest: sha256:7cfe34701992434cc08bfd40e80e04ab406522214cf9bbefa57a5432a123b340
Status: Downloaded newer image for jenkins/jenkins:lts

启动一个名为jenkins的容器,并且将容器的8080和50000端口直接映射到本机的8080和50000端口,文件对应本地的/usr/local/workspace/jenkins

docker run -p 8080:8080 -p 50000:50000 -v /usr/local/workspace/jenkins:/var/jenkins_home --name jenkins -idt jenkins/jenkins:lts
Unable to find image 'jenkins:latest' locally
latest: Pulling from library/jenkins
55cbf04beb70: Pull complete
1607093a898c: Pull complete
9a8ea045c926: Pull complete
d4eee24d4dac: Pull complete
c58988e753d7: Pull complete
794a04897db9: Pull complete
70fcfa476f73: Pull complete
0539c80a02be: Pull complete
54fefc6dcf80: Pull complete
911bc90e47a8: Pull complete
38430d93efed: Pull complete
7e46ccda148a: Pull complete
c0cbcb5ac747: Pull complete
35ade7a86a8e: Pull complete
aa433a6a56b1: Pull complete
841c1dd38d62: Pull complete
b865dcb08714: Pull complete
5a3779030005: Pull complete
12b47c68955c: Pull complete
1322ea3e7bfd: Pull complete
Digest: sha256:eeb4850eb65f2d92500e421b430ed1ec58a7ac909e91f518926e02473904f668
Status: Downloaded newer image for jenkins:latest
7c0c83b83707e40c879156449ea783a24a984fab9a3105e62b298d3a00ffdfaa

(3)验证是否安装成功

执行命令docker logs -f jenkins查看容器的控制台日志,看到如下信息表示jenkins服务启动成功

Aug 29, 2019 5:49:10 AM hudson.model.UpdateSite updateData
INFO: Obtained the latest update center data file for UpdateSource default
Aug 29, 2019 5:49:10 AM hudson.WebAppMain$3 run
INFO: Jenkins is fully up and running
Aug 29, 2019 5:49:39 AM hudson.model.DownloadService$Downloadable load
INFO: Obtained the updated data file for hudson.tasks.Maven.MavenInstaller
Aug 29, 2019 5:49:41 AM hudson.model.DownloadService$Downloadable load
INFO: Obtained the updated data file for hudson.tools.JDKInstaller
Aug 29, 2019 5:49:41 AM hudson.model.AsyncPeriodicWork$1 run
INFO: Finished Download metadata. 45,776 ms

或者docker ps -a | grep jenkins 看到up,表示运行状态

docker ps -a | grep jenkins
95e49fb019ce        jenkins              "/bin/tini -- /usr/l…"   6 seconds ago       Up 4 seconds                  0.0.0.0:8080->8080/tcp, 0.0.0.0:50000->50000/tcp   jenkins

如果想要开机自动重启容器,可以设置 docker update --restart=always jenkins

4,使用jenkins

(1)访问jenkins

http://192.168.1.119:8080,按照界面提示配置密码登录

页面提示密码文件的位置:/var/jenkins_home/secrets/initialAdminPassword,由于我们已经将/var/jenkins_home目录映射到本机的/usr/local/workspace/jenkins目录,所以密码文件在这个目录

(2)安装推荐插件,根据界面提示进行即可,耐心等待吧

问题:我遇到了,在安装完插件,如果重新刷新进入jenkins的时候,输入完第一步的密码之后,页面一直处于空白加载中,无法继续访问,搜查了网上资料解决了

在$JENKINS_HOME/hudson.model.UpdateCenter.xml文件中,也就是/usr/local/workspace/jenkins/hudson.model.UpdateCenter.xml默认内容如下

<?xml version='1.1' encoding='UTF-8'?>
<sites>
<site>
<id>default</id>
<url>https://updates.jenkins-ci.org/update-center.json</url>
</site>
</sites>
把url改成http://mirror.xmission.com/jenkins/updates/update-center.json
或者直接访问http://192.168.1.119:8080/pluginManager/advanced
然后在下面更改一下

(3)创建一个管理员账户,根据界面提示进行即可

问题:登录之后,可能显示空白页

访问http://192.168.1.119:8080/restart 登录管理员账户就可以了

Ubuntu+docker+jenkins安装详细指南的更多相关文章

  1. Centos + docker,Ubuntu + docker介绍安装及详细使用

    docker笔记 常用命令 设置docker开机自启:sudo chkconfig docker on 查所有镜像: docker images 删除某个镜像:docker rmi CONTAINER ...

  2. VMware Tools (ubuntu系统)安装详细过程与使用

    前一段时间博主在VMware虚拟机上安装了Ubuntu系统,如果还没有安装的同学可以参考博主上一篇文章:VMware Ubuntu安装详细过程. 猿友们都知道linux不太好用,如果你想将你主机Win ...

  3. ubuntu docker inflxudb(安装 使用 备份 还原 以及python编码) telegraf Grafana

    inflxudb1.7.7 1.拉取最新的镜像 docker pull influxdb 2.运行实例: docker run -d --restart=always -p 8086:8086 -p ...

  4. Ubuntu 虚拟机环境安装配置指南

    1. 安装Ubuntu到虚拟机. 到 Ubuntu 上下载桌面版iso文件,加载到虚拟机,开始安装,傻瓜式操作不用多说.2. 调整屏幕分辨率. 虚拟机软件我是用的virtual box,在工具栏上设备 ...

  5. jenkins安装详细教程

    一.jenkins简介 jenkins是一个开源的软件项目,是基于java开发的一种持续集成工具,用于监控持续重复的工作,旨在提供一个开放易用的软件平台,使软件的持续集成变成可能. 1.持续的软件版本 ...

  6. ubuntu docker的安装和使用

    Docker CE for Ubuntu Docker CE for Ubuntu is the best way to install the Docker platform on Ubuntu L ...

  7. Ubuntu Docker 简单安装 GitLab

    相关博文: Ubuntu 简单安装 Docker Ubuntu 简单安装和配置 GitLab 服务器版本 Ubuntu 16.04 LTS. 1. 安装和配置 安装命令: sudo docker ru ...

  8. docker jenkins安装(一)

    https://hub.docker.com/r/jenkins/jenkins  jenkins的docker官方镜像地址 https://jenkins.io/  jenkins官方网站 环境: ...

  9. Ubuntu VMware Tools安装详细过程(非常靠谱)

    说明:该篇博客是博主一字一码编写的,实属不易,请尊重原创,谢谢大家! 一.前言 VMware Ubuntu安装以及详细过程:https://blog.csdn.net/qq_41782425/arti ...

随机推荐

  1. Flink的Job启动JobManager端(源码分析)

    通过前面的文章了解到 Driver将用户代码转换成streamGraph再转换成Jobgraph后向Jobmanager端提交 JobManager启动以后会在Dispatcher.java起来RPC ...

  2. 新手学习FFmpeg - 调用API完成录屏

    调用FFMPEG Device API完成Mac录屏功能. 调用FFMPEG提供的API来完成录屏功能,大致的思路是: 打开输入设备. 打开输出设备. 从输入设备读取视频流,然后经过解码->编码 ...

  3. Unity官方案例精讲_2015_优化

    1.将公共变量从Inspector视图中隐藏:    [HideInInspector] [HideInInspector] public GameObject player; 2.限定Inspect ...

  4. 命令行通过入参调用jar包

    命令行通过入参调用jar包 最近因为项目需要,需要实现一个功能,即定时执行服务器上的一个脚本去对数据库的数据进行业务处理,要操作的数据库有很多种,mysql.db2.oracle.sqlserver等 ...

  5. list 分批

    public class TestList { public static void main(String[] args){ List<Integer> list = new Array ...

  6. cogs 1199选课(树形dp 背包或多叉转二叉

    http://cogs.pro:8080/cogs/problem/problem.php?pid=vQyiJkkPP 题意:给m门课,每门课在上完其先修课后才能上,要你从中选n门课使得总学分尽可能大 ...

  7. 牛客多校第七场 C Bit Compression 思维

    链接:https://www.nowcoder.com/acm/contest/145/C来源:牛客网 A binary string s of length N = 2n is given. You ...

  8. Array List和Linked List实现分析

    一,前言 ​ 先来一张Collection集合图. ​ 今天分享一些关于Collection集合中的List,讲真的集合这东西在网上真是老生常谈了.说实话连本人都觉得腻了(哈哈),但是话又说回来,整个 ...

  9. Spring 两大核心 IOC 和 AOP

    如果你的简历上写着Spring (请详述一下spring的两大核心)这个问题一定会被问到. 一.什么叫IOC 1. IOC 全称(Inversion of Control)-- 控制反转. IOC 只 ...

  10. Linux系统下安装zookeeper教程

    环境: 1.VMware® Workstation 12 Pro 2.CentOS7 3.zookeeper-3.4.6 安装步骤 1.下载zookeeper 本文使用的zookeeper下载地址如下 ...