系列文章:
前言
jenkins是常用的开源持续继承工具,现在所在的工作场景,也是使用jenkins进行基于github代码的拉取、打包、构建、部署的一系列流程,并结合了容器和函数计算实现金丝雀部署。本文先从基础的jenkins环境搭建开始。
一 jenkins本地安装部署
jenkins官网的下载速度太慢,可使用下面镜像:
官网文档,jenkins入门,下载jenkins.war之后,使用下面命令启动和访问:
1.下载 Jenkins.
- 2.打开终端进入到下载目录.
- 3.运行命令
java -jar jenkins.war --httpPort=8080
. - 4.打开浏览器进入链接
http://localhost:8080
. - 5.按照说明完成安装.
按照说明,java -jar jenkins.war --httpPort=8080 后控制台输出如下:
-rw-r--r--@ 1 qingclass staff 66175731 2 7 16:28 jenkins.war bogon:jenkins qingclass$ bogon:jenkins qingclass$ bogon:jenkins qingclass$ java -jar jenkins.war --httpPort=8080 Running from: /Users/qingclass/develop/mine/projects/container/jenkins/jenkins.war webroot: $user.home/.jenkins 2021-02-07 08:28:58.638+0000 [id=1] INFO org.eclipse.jetty.util.log.Log#initialized: Logging initialized @450ms to org.eclipse.jetty.util.log.JavaUtilLog 2021-02-07 08:28:58.751+0000 [id=1] INFO winstone.Logger#logInternal: Beginning extraction from war file 2021-02-07 08:29:00.126+0000 [id=1] WARNING o.e.j.s.handler.ContextHandler#setContextPath: Empty contextPath 2021-02-07 08:29:00.180+0000 [id=1] INFO org.eclipse.jetty.server.Server#doStart: jetty-9.4.25.v20191220; built: 2019-12-20T17:00:00.294Z; git: a9729c7e7f33a459d2616a8f9e9ba8a90f432e95; jvm 1.8.0_212-b10 2021-02-07 08:29:00.447+0000 [id=1] INFO o.e.j.w.StandardDescriptorProcessor#visitServlet: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet 2021-02-07 08:29:00.486+0000 [id=1] INFO o.e.j.s.s.DefaultSessionIdManager#doStart: DefaultSessionIdManager workerName=node0 2021-02-07 08:29:00.486+0000 [id=1] INFO o.e.j.s.s.DefaultSessionIdManager#doStart: No SessionScavenger set, using defaults 2021-02-07 08:29:00.491+0000 [id=1] INFO o.e.j.server.session.HouseKeeper#startScavenging: node0 Scavenging every 600000ms 2021-02-07 08:29:00.768+0000 [id=1] INFO hudson.WebAppMain#contextInitialized: Jenkins home directory: /Users/qingclass/.jenkins found at: $user.home/.jenkins 2021-02-07 08:29:02.331+0000 [id=1] INFO o.e.j.s.handler.ContextHandler#doStart: Started w.@1cf2fed4{Jenkins v2.220,/,file:///Users/qingclass/.jenkins/war/,AVAILABLE}{/Users/qingclass/.jenkins/war} 2021-02-07 08:29:02.363+0000 [id=1] INFO o.e.j.server.AbstractConnector#doStart: Started ServerConnector@1a4927d6{HTTP/1.1,[http/1.1]}{0.0.0.0:8080} 2021-02-07 08:29:02.363+0000 [id=1] INFO org.eclipse.jetty.server.Server#doStart: Started @4176ms 2021-02-07 08:29:02.364+0000 [id=23] INFO winstone.Logger#logInternal: Winstone Servlet Engine running: controlPort=disabled 2021-02-07 08:29:03.159+0000 [id=30] INFO jenkins.InitReactorRunner$1#onAttained: Started initialization 2021-02-07 08:29:03.174+0000 [id=50] INFO jenkins.InitReactorRunner$1#onAttained: Listed all plugins 2021-02-07 08:29:04.066+0000 [id=37] INFO jenkins.InitReactorRunner$1#onAttained: Prepared all plugins 2021-02-07 08:29:04.071+0000 [id=37] INFO jenkins.InitReactorRunner$1#onAttained: Started all plugins 2021-02-07 08:29:04.076+0000 [id=45] INFO jenkins.InitReactorRunner$1#onAttained: Augmented all extensions 2021-02-07 08:29:04.637+0000 [id=50] INFO jenkins.InitReactorRunner$1#onAttained: System config loaded 2021-02-07 08:29:04.637+0000 [id=40] INFO jenkins.InitReactorRunner$1#onAttained: System config adapted 2021-02-07 08:29:04.637+0000 [id=48] INFO jenkins.InitReactorRunner$1#onAttained: Loaded all jobs 2021-02-07 08:29:04.638+0000 [id=48] INFO jenkins.InitReactorRunner$1#onAttained: Configuration for all jobs updated 2021-02-07 08:29:04.647+0000 [id=64] INFO hudson.model.AsyncPeriodicWork#lambda$doRun$0: Started Download metadata 2021-02-07 08:29:04.656+0000 [id=64] INFO hudson.util.Retrier#start: Attempt #1 to do the action check updates server 2021-02-07 08:29:05.281+0000 [id=31] INFO o.s.c.s.AbstractApplicationContext#prepareRefresh: Refreshing org.springframework.web.context.support.StaticWebApplicationContext@b824f1b: display name [Root WebApplicationContext]; startup date [Sun Feb 07 16:29:05 CST 2021]; root of context hierarchy 2021-02-07 08:29:05.281+0000 [id=31] INFO o.s.c.s.AbstractApplicationContext#obtainFreshBeanFactory: Bean factory for application context [org.springframework.web.context.support.StaticWebApplicationContext@b824f1b]: org.springframework.beans.factory.support.DefaultListableBeanFactory@5dd6b4ad 2021-02-07 08:29:05.290+0000 [id=31] INFO o.s.b.f.s.DefaultListableBeanFactory#preInstantiateSingletons: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@5dd6b4ad: defining beans [authenticationManager]; root of factory hierarchy 2021-02-07 08:29:05.427+0000 [id=31] INFO o.s.c.s.AbstractApplicationContext#prepareRefresh: Refreshing org.springframework.web.context.support.StaticWebApplicationContext@11ce086b: display name [Root WebApplicationContext]; startup date [Sun Feb 07 16:29:05 CST 2021]; root of context hierarchy 2021-02-07 08:29:05.427+0000 [id=31] INFO o.s.c.s.AbstractApplicationContext#obtainFreshBeanFactory: Bean factory for application context [org.springframework.web.context.support.StaticWebApplicationContext@11ce086b]: org.springframework.beans.factory.support.DefaultListableBeanFactory@79f651d3 2021-02-07 08:29:05.427+0000 [id=31] INFO o.s.b.f.s.DefaultListableBeanFactory#preInstantiateSingletons: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@79f651d3: defining beans [filter,legacy]; root of factory hierarchy 2021-02-07 08:29:05.561+0000 [id=31] 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: 1072ca47a779473dbad450aee6d6946e This may also be found at: /Users/qingclass/.jenkins/secrets/initialAdminPassword
浏览器访问,注意,页面会提示等待初始化,结束后会自动跳转到首页,这个过程会花1-2分钟时间,并非出错。
待弹出上面这个输入秘钥页面时,输入上面的1072ca47a779473dbad450aee6d6946e 完成安装,进入后续操作即可。
完成后,进入熟悉的页面:
二 docker下的安装部署
注,这里不再介绍docker的安装方式,默认已完成本地的docker部署。
笔者使用的docker版本如下:
flamingskys:logs $ docker --version Docker version 19.03.5, build 633a0ea
在docker中下载并安装jenkins,可参照说明: docker中安装jenkins,使用镜像: jenkinsci/blueocean,这是来自 Docker Hub repository 的jenkins Docker镜像。
安装步骤:
1、使用下面命令直接运行:
docker run -p 8080:8080 jenkinsci/blueocean
2、run成功后,当看到下面输出时,代表已经启动完成。浏览器中通过http://localhost:8080端口访问,与本地部署相同:密码: d71cb009aa2e4343896110ccbc86778d