Jenkins安装部署

Jenkins

Docker Jenkins

1
docker pull jenkins/jenkins:2.235.5-lts-centos7
1
2
#jenkins启动用户id 1000
chown -R 1000:1000 ~/docker/jenkins
1
docker run -d --name jenkins -p 8080:8080 -p 50000:50000 -e "LANG=en_US.UTF-8" -e "JAVA_OPTS=-Duser.timezone=Asia/Shanghai -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8" -v ~/docker/jenkins:/var/jenkins_home  jenkins/jenkins:2.235.5-lts-centos7

设置默认用户名 https://github.com/foxylion/docker-jenkins/blob/master/docker-images/master/default-user.groovy

Nginx 反向代理

https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+behind+an+NGinX+reverse+proxy

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
upstream jenkins {
server 127.0.0.1:8080 fail_timeout=0;
}

server {
listen 80;
server_name jenkins.domain.tld;
return 301 https://$host$request_uri;
}

server {
listen 443 ssl;
server_name jenkins.domain.tld;

ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;

location / {
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect http:// https://;
proxy_pass http://jenkins;
# Required for new HTTP-based CLI
proxy_http_version 1.1;
proxy_request_buffering off;
proxy_buffering off; # Required for HTTP-based CLI to work over SSL
# workaround for https://issues.jenkins-ci.org/browse/JENKINS-45651
add_header 'X-SSH-Endpoint' 'jenkins.domain.tld:50022' always;
}
}

插件

Jenkins插件源使用国内镜像中心的最新方法_DevOps持续集成的博客-CSDN博客_jenkins 插件源

https://hub.docker.com/r/jenkinszh/jenkins-zh/dockerfile

Folders

Git

Email Extension

Credentials Binding

SSH Build Agents

Localization: Chinese (Simplified)

节点

ssh-agent

https://github.com/jenkinsci/ssh-slaves-plugin/blob/master/doc/CONFIGURE.md

ssh-slave 镜像和 ssh-agent 镜像 dockerfile内容一致。底层镜像 adoptopenjdk/openjdk8:jdk8u262-b10-alpine

https://hub.docker.com/r/jenkins/ssh-agent/dockerfile

https://hub.docker.com/r/jenkins/ssh-slave/dockerfile

1
docker pull jenkins/ssh-agent:3.0.0

生成 key

1
ssh-keygen -f pemkey -m PEM -t ed25519

运行

1
docker run -d --name jenkins-ssh-agent jenkins/ssh-agent:3.0.0 "ssh 公钥"

问题

执行 shell 后不删除 jenkins 启动的子 shell

shell 添加 BUILD_ID=DONTKILLME

参考

docker运行jenkins

Create a HTTP proxy for jenkins using NGINX.

docker容器的时区问题和中文问题

Jenkins

Installing Jenkins with Docker

×

纯属好玩

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

文章目录
  1. 1. Jenkins
    1. 1.1. Docker Jenkins
    2. 1.2. Nginx 反向代理
    3. 1.3. 插件
      1. 1.3.1. Folders
      2. 1.3.2. Git
      3. 1.3.3. Email Extension
      4. 1.3.4. Credentials Binding
      5. 1.3.5. SSH Build Agents
      6. 1.3.6. Localization: Chinese (Simplified)
    4. 1.4. 节点
      1. 1.4.1. ssh-agent
    5. 1.5. 问题
      1. 1.5.1. 执行 shell 后不删除 jenkins 启动的子 shell
    6. 1.6. 参考
,