安装

地址 https://www.jenkins.io/download/

ubuntu

安装 Java环境

  1. sudo apt-get install openjdk-8-jre

jekins

  1. wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
  2. sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > \
  3. /etc/apt/sources.list.d/jenkins.list'
  4. sudo apt-get update
  5. sudo apt-get install jenkins

centos

安装java环境 http://openjdk.java.net/install/index.html

  1. yum install java-1.8.0-openjdk

安装

  1. sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
  2. sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
  3. sudo yum install jenkins

启动

  1. sudo systemctl start jenkins

查看启动结果

  1. sudo systemctl status jenkins

访问{ip}:8080
image.png

获取初始化密码

image.png
查看初始化密码

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

docker 权限

  1. Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post

查看jekins 用户

  1. cat /etc/passwd |grep jenkins
  2. jenkins:x:112:116:Jenkins,,,:/var/lib/jenkins:/bin/bash

增加用户到jekins

  1. sudo gpasswd -a jenkins docker
  2. Adding user jenkins to group docker

重启jenkins

  1. systemctl restart jenkins

Please wait while Jenkins is getting ready to work

image.png
查找文件 hudson.model.UpdateCenter.xml

  1. # find / -name "hudson.model.UpdateCenter.xml"
  2. /var/lib/jenkins/hudson.model.UpdateCenter.xml

修改文件

  1. <?xml version='1.1' encoding='UTF-8'?>
  2. <sites>
  3. <site>
  4. <id>default</id>
  5. <url>https://updates.jenkins.io/update-center.json</url>
  6. </site>
  7. </sites>

执行vim /var/lib/jenkins/hudson.model.UpdateCenter.xml
将 url 中的 https://updates.jenkins.io/update-center.json 更改为https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json 是国内的清华大学的镜像地址。

重启Jenkins

  1. systemctl restart jenkins

docker插件

  1. groovy.lang.MissingPropertyException: No such property: docker for class: groovy.lang.Binding

搜索插件docker pipeline
image.png

blueocean

Blue ocean 是Jenkins的一种新的UI 界面

选择插件安装Blue ocean
image.png

然后重启jekins 打开blue Ccean
image.png

效果
image.png

参考

https://www.jenkins.io/doc/book/installing/linux/
https://github.com/jenkinsci/docker/blob/master/README.md
https://www.cnblogs.com/qiaozhuangshi/p/11762330.html
https://juejin.cn/post/6844904159838208013
https://blog.csdn.net/wade3015/article/details/95633077