自动化项目部署系列:安装Jenkins

朱治龙
2022-01-28 / 0 评论 / 36 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2022年01月29日,已超过1075天没有更新,若内容或图片失效,请留言反馈。

拉取镜像

docker pull jenkins/jenkins:lts

执行后显示如下信息:

[zhuzl@VM-16-6-centos ~]$ sudo docker pull jenkins/jenkins:lts
lts: Pulling from jenkins/jenkins
647acf3d48c2: Pull complete 
832e288237bc: Pull complete 
ea194d1bd1da: Pull complete 
98569593b9fd: Pull complete 
dfe249e8cdf2: Pull complete 
0f6f2e6d37bb: Pull complete 
07fcb98649b6: Pull complete 
1e33c26b1882: Pull complete 
7b24f0e29fe1: Pull complete 
4d90ef3a8f3b: Pull complete 
d98c8e675bea: Pull complete 
b45fc2bf9fd7: Pull complete 
d6e1fda9effc: Pull complete 
3635a44047f2: Pull complete 
486e1776d3bc: Pull complete 
41233d151800: Pull complete 
14a67803c2b3: Pull complete 
Digest: sha256:c1d02293a08ba69483992f541935f7639fb10c6c322785bdabaf7fa94cd5e732
Status: Downloaded newer image for jenkins/jenkins:lts
docker.io/jenkins/jenkins:lts
[zhuzl@VM-16-6-centos ~]$ 

创建磁盘卷

sudo docker volume create jenkins_data

执行后显示如下信息:

[zhuzl@VM-16-6-centos ~]$ sudo docker volume create jenkins_data
jenkins_data
[zhuzl@VM-16-6-centos ~]$

启动容器

sudo docker run -d --name jenkins --restart always -p 8003:8080 -v jenkins_data:/var/jenkins_home jenkins/jenkins:lts

执行后显示如下信息:

[zhuzl@VM-16-6-centos ~]$ sudo docker run -d --name jenkins --restart always -p 8003:8080 -v jenkins_data:/var/jenkins_home jenkins/jenkins:lts
ba1dc70b3621c93515eb818daf1600f50a54b441de102319f23152f98b6b7aec
[zhuzl@VM-16-6-centos ~]$

通过docker logs xxxx 查看控制台信息,显示如下信息:

[zhuzl@VM-16-6-centos ~]$ sudo docker logs ba1d
Running from: /usr/share/jenkins/jenkins.war
webroot: EnvVars.masterEnvVars.get("JENKINS_HOME")
2022-01-28 09:13:17.975+0000 [id=1]     INFO    org.eclipse.jetty.util.log.Log#initialized: Logging initialized @469ms to org.eclipse.jetty.util.log.JavaUtilLog
2022-01-28 09:13:18.045+0000 [id=1]     INFO    winstone.Logger#logInternal: Beginning extraction from war file
2022-01-28 09:13:19.065+0000 [id=1]     WARNING o.e.j.s.handler.ContextHandler#setContextPath: Empty contextPath
2022-01-28 09:13:19.126+0000 [id=1]     INFO    org.eclipse.jetty.server.Server#doStart: jetty-9.4.43.v20210629; built: 2021-06-30T11:07:22.254Z; git: 526006ecfa3af7f1a27ef3a288e2bef7ea9dd7e8; jvm 11.0.13+8
2022-01-28 09:13:19.360+0000 [id=1]     INFO    o.e.j.w.StandardDescriptorProcessor#visitServlet: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
2022-01-28 09:13:19.395+0000 [id=1]     INFO    o.e.j.s.s.DefaultSessionIdManager#doStart: DefaultSessionIdManager workerName=node0
2022-01-28 09:13:19.396+0000 [id=1]     INFO    o.e.j.s.s.DefaultSessionIdManager#doStart: No SessionScavenger set, using defaults
2022-01-28 09:13:19.397+0000 [id=1]     INFO    o.e.j.server.session.HouseKeeper#startScavenging: node0 Scavenging every 660000ms
2022-01-28 09:13:19.829+0000 [id=1]     INFO    hudson.WebAppMain#contextInitialized: Jenkins home directory: /var/jenkins_home found at: EnvVars.masterEnvVars.get("JENKINS_HOME")
2022-01-28 09:13:20.000+0000 [id=1]     INFO    o.e.j.s.handler.ContextHandler#doStart: Started w.@3f049056{Jenkins v2.328,/,file:///var/jenkins_home/war/,AVAILABLE}{/var/jenkins_home/war}
2022-01-28 09:13:20.022+0000 [id=1]     INFO    o.e.j.server.AbstractConnector#doStart: Started ServerConnector@45e37a7e{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
2022-01-28 09:13:20.022+0000 [id=1]     INFO    org.eclipse.jetty.server.Server#doStart: Started @2518ms
2022-01-28 09:13:20.026+0000 [id=24]    INFO    winstone.Logger#logInternal: Winstone Servlet Engine running: controlPort=disabled
2022-01-28 09:13:20.249+0000 [id=31]    INFO    jenkins.InitReactorRunner$1#onAttained: Started initialization
2022-01-28 09:13:20.273+0000 [id=30]    INFO    jenkins.InitReactorRunner$1#onAttained: Listed all plugins
2022-01-28 09:13:20.985+0000 [id=32]    INFO    jenkins.InitReactorRunner$1#onAttained: Prepared all plugins
2022-01-28 09:13:20.990+0000 [id=31]    INFO    jenkins.InitReactorRunner$1#onAttained: Started all plugins
2022-01-28 09:13:20.995+0000 [id=35]    INFO    jenkins.InitReactorRunner$1#onAttained: Augmented all extensions
2022-01-28 09:13:21.409+0000 [id=35]    INFO    jenkins.InitReactorRunner$1#onAttained: System config loaded
2022-01-28 09:13:21.409+0000 [id=35]    INFO    jenkins.InitReactorRunner$1#onAttained: System config adapted
2022-01-28 09:13:21.409+0000 [id=35]    INFO    jenkins.InitReactorRunner$1#onAttained: Loaded all jobs
2022-01-28 09:13:21.410+0000 [id=35]    INFO    jenkins.InitReactorRunner$1#onAttained: Configuration for all jobs updated
2022-01-28 09:13:21.429+0000 [id=49]    INFO    hudson.model.AsyncPeriodicWork#lambda$doRun$1: Started Download metadata
2022-01-28 09:13:21.441+0000 [id=49]    INFO    hudson.util.Retrier#start: Attempt #1 to do the action check updates server
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/var/jenkins_home/war/WEB-INF/lib/groovy-all-2.4.21.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2022-01-28 09:13:21.779+0000 [id=35]    INFO    jenkins.install.SetupWizard#init: 

*************************************************************
*************************************************************
*************************************************************

Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:

8420f23681df4e6c90ca9babdb4c366a

This may also be found at: /var/jenkins_home/secrets/initialAdminPassword

*************************************************************
*************************************************************
*************************************************************

2022-01-28 09:13:34.191+0000 [id=33]    INFO    jenkins.InitReactorRunner$1#onAttained: Completed initialization
2022-01-28 09:13:34.209+0000 [id=23]    INFO    hudson.WebAppMain$3#run: Jenkins is fully up and running
[zhuzl@VM-16-6-centos ~]$

通过 sudo docker inspect jenkins_data, 可查看磁盘卷在本地的目录:

[zhuzl@VM-16-6-centos ~]$ sudo docker inspect jenkins_data
[
    {
        "CreatedAt": "2022-01-28T17:13:34+08:00",
        "Driver": "local",
        "Labels": {},
        "Mountpoint": "/var/lib/docker/volumes/jenkins_data/_data",
        "Name": "jenkins_data",
        "Options": {},
        "Scope": "local"
    }
]
[zhuzl@VM-16-6-centos ~]$

查看jenkins 密码:

[zhuzl@VM-16-6-centos ~]$ sudo cat /var/lib/docker/volumes/jenkins_data/_data/secrets/initialAdminPassword
8420f23681df4e6c90ca9babdb4c366a
[zhuzl@VM-16-6-centos ~]$

访问Jenkins应用

通过nginx 代理后,访问应用,界面效果如下:
kyy75hon.png

输入上面查看到的管理员密码信息:8420f23681df4e6c90ca9babdb4c366a,单击“下一步”按钮,显示loading界面:
kyy76l53.png

loading加载完成后,显示如下自定义配置界面:
kyy77z8i.png

这里我选择“安装推荐的插件”,进入如下图所示的推荐插件安装界面:
kyy796uj.png

插件安装完成后,进入如下图所示的管理员设置界面:
kyy7eu5r.png

填写完管理员信息后,单击“保存并完成”按钮,进入如下图所示的实例配置界面:
kyy7got3.png

再次单击“保存并完成”按钮,显示如下图所示的“Jenkins已就绪!”界面
kyy7hiqo.png

单击“开始使用jenkins”按钮,进入如下图所示的 Jenkins 主界面:
kyy7k2j1.png

0

评论 (0)

取消