1. 查看默认密码

  1. cat /var/lib/jenkins/secrets/initialAdminPassword

2. 解决安装Jenkins时web界面出现该jenkins实例似乎已离线

2.1 修改/var/lib/jenkins/updates/default.json

jenkins在下载插件之前会先检查网络连接,其会读取这个文件中的网址。默认是:
访问谷歌,这就很坑了,服务器网络又不能FQ,肯定监测失败呀,不得不说jenkins的开发者脑子锈了,所以将配置文件中的的www.google.com改为www.baidu.com即可,更改完重启服务

2.2 修改/var/lib/jenkins/hudson.model.UpdateCenter.xml

该文件为jenkins下载插件的源地址,改地址默认jenkins默认为:https://updates.jenkins.io/update-center.json,就是因为https的问题,此处我们将其改为http即可,之后重启jenkins服务即可。
其他国内备用地址(也可以选择使用):
https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json
http://mirror.esuni.jp/jenkins/updates/update-center.json
更改完重启服务

3. jenkins组件

3.1 parameterized Trigger plugin

每次点击一个项目之后 它就会在构建完成之后在对设置的项目进行构建

3.2 build pipeline plugin

只需要构建一个项目,就会帮我们完成所有相关项目

jenkins

一直的疑问?为什么在jenkins官方文档要docker in docker? 而且在启动jenkins之前还要再启一个dokcer:dind的容器
官方解释:


The recommended Docker image to use is the Official jenkins/jenkinsimage (from the Docker Hub repository). This image contains the current Long-Term Support (LTS) release of Jenkins (which is production-ready). However this image doesn’t have docker CLI inside it and is not bundled with frequently used Blue Ocean plugins and features. This means that if you want to use the full power of Jenkins and Docker you may want to go through described below installation process.


推荐使用的Docker映像是官方的jenkins/jenkins映像(来自Docker Hub存储库)。这张图片包含Jenkins的当前长期支持(LTS)版本(已准备好生产)。但是,该映像中没有docker CLI,也没有与常用的Blue Ocean插件和功能捆绑在一起。这意味着,如果你想充分利用Jenkins和Docker的力量,你可能需要完成下面描述的安装过程。
就是在容器里安装jenkins之前再启动一个docker:dind的容器
于是就在网上翻到了这些文章

上面的链接是解释了一些docker in docker 问题不断优化的过程
下面的链接引用这个链接然后又结合了jenkins实际用处


In Jenkins, all the commands in the stages of your pipeline are executed on the agent that you specify. This agent can be a Docker container. So, if one of your commands, for example, in the Build stage, is a Docker command (for example, for building an image), then you have the case that you need to run a Docker command within a Docker container.


意思大致解释就是jenkins是一个持续CICD的过程,有的流水线需要docker命令
但是jenkins不是搭建在宿主机上的,而是在容器内部,这时就需要在容器内部有docker-cli
这时候又想到一个问题就是说为什么不直接启动Jenkins的时候直接关联宿主机的docker 呢

docker run -ti -v /var/run/docker.sock:/var/run/docker.sock

经自己在本地实验后发现了为什么这样设计?
1、前文也提到docker in docker 会产生莫名的问题
2、jenkins容器关联到docker:dind容器,镜像容器是内部公用的,而却与宿主机的docker隔离开,防止后期jenkins在构建的时候宿主机产生大量的镜像,不易于管理