云原生之docker部署jenkins持续集成工具
【摘要】 云原生之docker部署jenkins持续集成工具
一、jenkins介绍
Jenkins是一个开源软件项目,是基于Java开发的一种持续集成工具,用于监控持续重复的工作,旨在提供一个开放易用的软件平台,使软件项目可以进行持续集成。
二、jenkins功能
- 一个自动构建过程,包括自动编译、分发、部署和测试等。
- 一个代码存储库,即需要版本控制软件来保障代码的可维护性,同时作为构建过程的素材库。
- 一个持续集成服务器。
三、检查本地docker状态
[root@node ~]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2022-11-06 06:02:26 CST; 6min ago
Docs: https://docs.docker.com
Main PID: 9869 (dockerd)
Tasks: 76
Memory: 185.2M
CGroup: /system.slice/docker.service
├─ 9869 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
├─20064 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 3548 -container-ip 172.17.0.2 -container-port 3306
├─20074 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 3548 -container-ip 172.17.0.2 -container-port 3306
├─20107 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8080 -container-ip 172.17.0.3 -container-port 80
├─20113 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 8080 -container-ip 172.17.0.3 -container-port 80
├─20489 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 9010 -container-ip 172.17.0.4 -container-port 9000
├─20495 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 9010 -container-ip 172.17.0.4 -container-port 9000
├─20514 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8120 -container-ip 172.17.0.4 -container-port 80
├─20525 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 8120 -container-ip 172.17.0.4 -container-port 80
├─20563 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 443 -container-ip 172.17.0.4 -container-port 443
└─20574 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 443 -container-ip 172.17.0.4 -container-port 443
Nov 06 06:02:22 node dockerd[9869]: time="2022-11-06T06:02:22.858540089+08:00" level=info msg="Removing stale sandbox 1f9c7c1980061b426...89cfa96)"
Nov 06 06:02:22 node dockerd[9869]: time="2022-11-06T06:02:22.873645768+08:00" level=warning msg="Error (Unable to complete atomic oper...ying...."
Nov 06 06:02:22 node dockerd[9869]: time="2022-11-06T06:02:22.953940543+08:00" level=info msg="Removing stale sandbox 4a120cc4b61f298f2...ec3e139)"
Nov 06 06:02:22 node dockerd[9869]: time="2022-11-06T06:02:22.954941579+08:00" level=warning msg="Error (Unable to complete atomic oper...ying...."
Nov 06 06:02:22 node dockerd[9869]: time="2022-11-06T06:02:22.982064143+08:00" level=info msg="Default bridge (docker0) is assigned wit... address"
Nov 06 06:02:26 node dockerd[9869]: time="2022-11-06T06:02:26.676985427+08:00" level=info msg="Loading containers: done."
Nov 06 06:02:26 node dockerd[9869]: time="2022-11-06T06:02:26.706262799+08:00" level=info msg="Docker daemon" commit=a89b842 graphdrive...=20.10.17
Nov 06 06:02:26 node dockerd[9869]: time="2022-11-06T06:02:26.706381481+08:00" level=info msg="Daemon has completed initialization"
Nov 06 06:02:26 node systemd[1]: Started Docker Application Container Engine.
Nov 06 06:02:26 node dockerd[9869]: time="2022-11-06T06:02:26.742893105+08:00" level=info msg="API listen on /var/run/docker.sock"
Hint: Some lines were ellipsized, use -l to show in full.
四、下载jenkins镜像
[root@node ~]# docker pull jenkins/jenkins
Using default tag: latest
latest: Pulling from jenkins/jenkins
0e29546d541c: Already exists
11bbb8c402a7: Pull complete
cf91f018150b: Pull complete
a98e88c6f0f0: Pull complete
f67fc70d671a: Pull complete
edbe48067464: Pull complete
fa23ca93dd6b: Pull complete
00159d993c13: Pull complete
f28fb40a17cf: Pull complete
071d309df04b: Pull complete
78599f36e494: Pull complete
896a32d969fb: Pull complete
3f1a51ea9f7f: Pull complete
26e724f0bfad: Pull complete
b377e1ae1384: Pull complete
d3cdbe7e8b9f: Pull complete
f3b40ebc3458: Pull complete
Digest: sha256:c3fa8e7f70d1e873ea6aa87040c557aa53e6707eb1d5ecace7f6884a87588ac8
Status: Downloaded newer image for jenkins/jenkins:latest
docker.io/jenkins/jenkins:latest
五、部署jenkins
1.创建数据目录
[root@node ~]# mkdir -p /data/jenkins/data
[root@node ~]# chmod -R 777 /data/jenkins/data/
[root@node ~]#
2.创建jenkins容器
[root@node jenkins]# docker run -d --name jenkins --restart always -p 8774:8080 -p 50100:50000 -v /data/jenkins/data/:/var/jenkins_home -v /etc/localtime:/etc/localtime jenkins/jenkins
b44ef8c88d09e5eebb996c91691101fb534859aa3185bdc8bf3c0a8ebf443cbf
3.查看jenkins容器状态
[root@node jenkins]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b44ef8c88d09 jenkins/jenkins "/sbin/tini -- /usr/…" 2 minutes ago Up 2 minutes 0.0.0.0:8774->8080/tcp, :::8774->8080/tcp, 0.0.0.0:50100->50000/tcp, :::50100->50000/tcp jenkins
六、配置jenkins镜像加速
[root@node data]# cat hudson.model.UpdateCenter.xml
<?xml version='1.1' encoding='UTF-8'?>
<sites>
<site>
<id>default</id>
<url>https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json</url>
</site>
</sites>
七、访问jenkins
[root@node data]# cat secrets/initialAdminPassword
9e501f00a41f472292367def3724d81b
[root@node data]#
八、jenkins初始化及安装插件
九、创建管理员账号
十、进入jenkins首页
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)