为什么国内做持续集成各人都选择 Jenkins ,用 travis-ci 的人那么少呢?
在之后的该文中如是说了Gitlab天然情况的修建和CI与Gitlab的资本整合,所以那时次要就如是说Docker中修建CI的天然情况,Docker问世于云计算的黄金时代,它次要是如前所述Go词汇与此同时实现的开放源码罐子工程项目,现阶段有关Docker罐子的生态系早已很健全,所以数十家非支流的功课系统子公司都全力撑持Docker。那时次要就如是说在Docker中修建Jenkins的天然情况,有关Docker天然情况的修建在中后期的该文中逐步的如是说。CI就不必要负担的如是说了, 它是智能化试验中要要掌控的两个专业技能寡所周知,与此同时也是与此同时实现CICD资本整合的核心理念辅助东西寡所周知。
加拆好Docker的天然情况之后,继续施行docker run hello-world,就会表白如下表所示的重要信息:
在docker中加拆Jenkins,详细来说必要找出Jenkins的快照,与此同时提议加拆新一代版的Jenkins,假设加拆的是旧版的,可能将引致的情形是那类应用法式难以加拆,或是是加拆之后不相容等情形。继续施行如下表所示指示以获取Jenkins的快照:
docker pull jenkins/jenkins:lts 见莱盖后的截屏重要信息:
接纳docker images查阅快照,见莱盖后输入的重要信息:
留下来莱盖docker inspect f32b4bb22e4d查阅快照的重要信息,见莱盖后输入的重要信息:
rlay2/712c41bbf566a5627b37e0a2f7c45614d8e38e251cca29c2cc82be7ff5c086a3/diff:/var/lib/docker/overlay2/52fed63ad6c6a130d2d25ae336125aa5c3fbc8cee0090fc802d4dd2b2d854a9c/diff:/var/lib/docker/overlay2/cb07495dd0929a97e7d8f29ab35b8a0c9550ae7b6872f0c642d00696f3f3991f/diff:/var/lib/docker/overlay2/119c563d38cadc9e5e1d1c0bcd96dc0d99951c4b811bf124c9114f2edc9ffe47/diff:/var/lib/docker/overlay2/2b496ab1f553fddaa4fea6ab915ef7e577df94dcc841634d69d6939700eb8201/diff:/var/lib/docker/overlay2/836acdc3c9d75e67d9e32f4eeda5f6ce43594c1691f28150ed677e266e8ba404/diff:/var/lib/docker/overlay2/096c6f4c13a62d8b8b6078cc889943272b40eb2b9973e86f7ea8b532f3620f6c/diff:/var/lib/docker/overlay2/a5be17cb6df7dee449c4b8e67cc59fc33e22bcacdfd9b00b73567b1d87f9a469/diff:/var/lib/docker/overlay2/c2360b1fe8d644057f44c6d3f97b00a64170f6a1e3966f63da80aa36f3983216/diff", "MergedDir": "/var/lib/docker/overlay2/c156aa815ff7d7b09b5cba868f4c0a4102e9b621f86cd3ea065f4b6f966e41f5/merged", "UpperDir": "/var/lib/docker/overlay2/c156aa815ff7d7b09b5cba868f4c0a4102e9b621f86cd3ea065f4b6f966e41f5/diff", "WorkDir": "/var/lib/docker/overlay2/c156aa815ff7d7b09b5cba868f4c0a4102e9b621f86cd3ea065f4b6f966e41f5/work" }, "Name": "overlay2" }, "RootFS": { "Type": "layers", "Layers": [ "sha256:f73e7e79899a33b4b9b78da62efb71520844f8dd518f3c390e27bc3063bce307", "sha256:d09a13f0562727a458ffbb3a66f6e74e70f8963f6bb813baa03c4a5af77c9dac", "sha256:057abc6c693757d66fb885c2e5c825cf27d3fb355f71eb69e72d6c9d3f27d25c", "sha256:e7c6a88ad7ae5b7246c905a16d5941b4292342778ce7125256bedf9864a99eab", "sha256:c109878b2e37f01fdcff763608401f33e33e60655bfbfa46c3ea2d0df4c6137c", "sha256:32c83575bd304d57d6f05123b63c14cc2df2fa7b38e247752716372a5634f652", "sha256:795c58d007a6a2956ce77c78ffa426dfe0d0972a6270b2215224b21edb039f2b", "sha256:cdfab899a401be8bb3eb7693abe57744991cb47efb9926205346526bfbd720b2", "sha256:72d2e37a9ce7a3ef770f7048e0c69e63a37de80b9d6d5bf1a9a8fdc5ea34c4a8", "sha256:e1787d4d466313e9d3c531683a7d66c50df82ff9fe46c53f0c6295d88dd86526", "sha256:c30202d911aada91d881a06e6a7d166a50416b6dd6c6065f5e58da399310d1bd", "sha256:1d04cc5c4d3141a9be518ba7f7c897e3017520f05561da3ef3c4643bc0c3e91a", "sha256:00cbc39c09c5db5056641762df60846eabf3b6b826d328f042eb74e78d0894c9", "sha256:9d016001a5f8ddfa6a691bb90f6729aa86b3566ca9fa5ac47ba3341e027ec59f", "sha256:849ee987421f2b41132075a44a9d9baa4d067573cc808b958eb04a970abfcf59", "sha256:a58e65c734eb9a0d4b9030920280a086a89efe5629224b8dd02c242e09463f82", "sha256:723ea0f5b90dd3d28678c8a0a1cf679139b32797fc0b00536b51413ad389ee7a", "sha256:b05f43802b1edc289418747bd37f26f46cb5411917d7a24b27ebf82c64211869", "sha256:dad9266a531c4f240b6aed46f1834a301b086b81420828828b30472ff6d3c85b" ] }, "Metadata": { "LastTagTime": "0001-01-01T00:00:00Z" } } ]在如上的重要信息中,就可以看到Jenkins的版为:JENKINS_VERSION=2.176.3。
留下来必要设置装备摆设Jenkins的目次,详细如下表所示如下表所示:
mkdir jenkins_home chown -R 1000 /root/jenkins_home/最初是在罐子中启动Docker了,启动的指示如下表所示:
docker run --name ci -p 8080:8080 -p 5000:5000 -v /r
oot/jenkins_home/:/var/jenkins_home jenkins/jenkins:lts
#那里对参数做一点解释,次要就为 --name:对快照自定义的名称, -p:映射罐子端口和办事器端口,8080端口是jenkins的端口,5000端口用于毗连Agent,-v:参数把jenins的home目次挂载到当地,继续施行如上的指示后,输入的log为:
Running from: /usr/share/jenkins/jenkins.war webroot: EnvVars.masterEnvVars.get("JENKINS_HOME") Sep 21, 2019 1:31:22 PM Main deleteWinstoneTempContents WARNING: Failed to delete the temporary Winstone file /tmp/winstone/jenkins.war Sep 21, 2019 1:31:22 PM org.eclipse.jetty.util.log.JavaUtilLog info INFO: Logging initialized @1180ms Sep 21, 2019 1:31:22 PM winstone.Logger logInternal INFO: Beginning extraction from war file Sep 21, 2019 1:31:24 PM org.eclipse.jetty.util.log.JavaUtilLog warn WARNING: Empty contextPath Sep 21, 2019 1:31:24 PM org.eclipse.jetty.util.log.JavaUtilLog info INFO: jetty-9.2.z-SNAPSHOT Sep 21, 2019 1:31:25 PM org.eclipse.jetty.util.log.JavaUtilLog info INFO: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet Jenkins home directory: /var/jenkins_home found at: EnvVars.masterEnvVars.get("JENKINS_HOME") Sep 21, 2019 1:31:26 PM org.eclipse.jetty.util.log.JavaUtilLog info INFO: Started w.@47404bea{/,file:/var/jenkins_home/war/,AVAILABLE}{/var/jenkins_home/war} Sep 21, 2019 1:31:26 PM org.eclipse.jetty.util.log.JavaUtilLog info INFO: Started ServerConnector@1c80e49b{HTTP/1.1}{0.0.0.0:8080} Sep 21, 2019 1:31:26 PM org.eclipse.jetty.util.log.JavaUtilLog info INFO: Started @5290ms Sep 21, 2019 1:31:26 PM winstone.Logger logInternal INFO: Winstone Servlet Engine v2.0 running: controlPort=disabled Sep 21, 2019 1:31:28 PM jenkins.InitReactorRunner$1 onAttained INFO: Started initialization Sep 21, 2019 1:31:28 PM jenkins.InitReactorRunner$1 onAttained INFO: Listed all plugins Sep 21, 2019 1:31:30 PM jenkins.InitReactorRunner$1 onAttained INFO: Prepared all plugins Sep 21, 2019 1:31:30 PM jenkins.InitReactorRunner$1 onAttained INFO: Started all plugins Sep 21, 2019 1:31:30 PM jenkins.InitReactorRunner$1 onAttained INFO: Augmented all extensions Sep 21, 2019 1:31:32 PM jenkins.InitReactorRunner$1 onAttained INFO: Loaded all jobs Sep 21, 2019 1:31:32 PM hudson.model.AsyncPeriodicWork$1 run INFO: Started Download metadata Sep 21, 2019 1:31:33 PM jenkins.util.groovy.GroovyHookScript execute INFO: Executing /var/jenkins_home/init.groovy.d/tcp-slave-agent-port.groovy Sep 21, 2019 1:31:34 PM jenkins.InitReactorRunner$1 onAttained INFO: Completed initialization Sep 21, 2019 1:31:34 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh INFO: Refreshing org.springframework.web.context.support.StaticWebApplicationContext@6c68e6e9: display name [Root WebApplicationContext]; startup date [Sat Sep 21 13:31:34 UTC 2019]; root of context hierarchy Sep 21, 2019 1:31:34 PM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory INFO: Bean factory for application context [org.springframework.web.context.support.StaticWebApplicationContext@6c68e6e9]: org.springframework.beans.factory.support.DefaultListableBeanFactory@76146d99 Sep 21, 2019 1:31:34 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@76146d99: defining beans [authenticationManager]; root of factory hierarchy Sep 21, 2019 1:31:34 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh INFO: Refreshing org.springframework.web.context.support.StaticWebApplicationContext@3cd45809: display name [Root WebApplicationContext]; startup date [Sat Sep 21 13:31:34 UTC 2019]; root of context hierarchy Sep 21, 2019 1:31:34 PM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory INFO: Bean factory for application context [org.springframework.web.context.support.StaticWebApplicationContext@3cd45809]: org.springframework.beans.factory.support.DefaultListableBeanFactory@dde78b7 Sep 21, 2019 1:31:34 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@dde78b7: defining beans [filter,legacy]; root of factory hierarchy Sep 21, 2019 1:31:35 PM jenkins.install.SetupWizard init INFO: ************************************************************* ************************************************************* ************************************************************* Jenkins initial setup is required. An admin user has been created and a password generated. Please use the following password to proceed to installation: f1bbfbb172cc4e92b2e0422b7b101d3f This may also be found at: /var/jenkins_home/secrets/initialAdminPassword ************************************************************* ************************************************************* ************************************************************* --> setting agent port for jnlp --> setting agent port for jnlp... done表白出如上的重要信息后,申明启动Jenkins已胜利,必要在阿里云的办事器开放8080的端口。接纳docker ps -a 能够查阅所有的罐子,见如下表所示截屏重要信息:
继续施行docker port ci查阅罐子的占用端口,见如下表所示的输入成果重要信息:
[root@wuya ~]# docker port ci 8080/tcp -> 0.0.0.0:8080 5000/tcp -> 0.0.0.0:5000 [root@wuya ~]#能够看到罐子占用的端口情形,当然也能够继续施行如下表所示的指示查阅端口的占用情形,详细为:
[root@wuya ~]# lsof -i:8080;lsof -i:5000 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME docker-pr 9811 root 4u IPv6 16411374 0t0 TCP *:webcache (LISTEN) COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME docker-pr 9828 root 4u IPv6 16411481 0t0 TCP *:commplex-main (LISTEN)Jenkins在罐子里面启动胜利后,与此同时8080的端口开放后,在阅读器输入http://x.x.x.x:8080/jenkins就会表白Jenkins的启动界面,如下表所示图所示:
留下来输入密码,然后是加拆应用法式以及点击Finish完成。当然下次在罐子里面怎么启动Jenkins了,继续施行docker ps -a | grep ci ,以获取到它的CONTAINER ID后,间接就能够启动或是停行,见指示:
[root@wuya ~]# docker stop bdf19546027b bdf19546027b [root@wuya ~]# docker port ci [root@wuya ~]# docker start bdf19546027b bdf19546027b [root@wuya ~]# docker port ci 5000/tcp -> 0.0.0.0:5000 8080/tcp -> 0.0.0.0:8080当然与此同时继续施行docker stats CONTAINER ID,就能够得到某两个罐子的资本接纳情形,如查阅Jenkins的,见如下表所示的输入重要信息:
谢谢您的存眷和阅读,您也可查阅我的其他系列该文。欢送购置我的册本和试验实战课程。
《Python智能化试验实战》(无涯)【摘要 书评 试读】- 京东图书item.jd.com/12516591.html Python接口智能化试验实战 - 网易云课堂study.163.com/course/courseMain.htm?courseId=1006358022&share=2&shareId=400000000650037