自动化领域比较有影响力的开源框架jenkins,确实比较强大,易用。很多公司将其用来做持续即成CI(continuous integration)。为了拓展和强化自己的软件设计生态系统,也将很久前使用过的jenkins再熟悉一下。在这里做下备忘。
首先就是下载jenkins安装包,其实所谓的安装,是习惯说法,这个直接从官网下载后,一个war包(jenkins.war, 60M大小左右),直接就可以启动运行。我本地安装的是最新版本1.644. 由于jenkins是java写的,运行过程中需要有JDK,即java要先安装且配置好JAVA_HOME。
查看下我的java home信息:
1 [root@CloudGame jenkins]# echo $JAVA_HOME 2 /usr/java/jdk1.8.0_65
这个基本要求具备后,就可以启动jenkins了,这里演示,就直接java -jar jenkins.war来启动,当然,jenkins也可以在任何servlet容器里面运行,比如Tomcat等。
1 [root@CloudGame jenkins]# java -jar jenkins.war 2 Running from: /home/webWps/jenkins/jenkins.war 3 webroot: $user.home/.jenkins 4 Jan 20, 2016 1:57:50 PM winstone.Logger logInternal 5 INFO: Beginning extraction from war file 6 Jan 20, 2016 1:57:50 PM org.eclipse.jetty.util.log.JavaUtilLog info 7 INFO: jetty-winstone-2.9 8 Jan 20, 2016 1:57:51 PM org.eclipse.jetty.util.log.JavaUtilLog info 9 INFO: NO JSP Support for , did not find org.apache.jasper.servlet.JspServlet 10 Jenkins home directory: /root/.jenkins found at: $user.home/.jenkins 11 Jan 20, 2016 1:57:52 PM org.eclipse.jetty.util.log.JavaUtilLog info 12 INFO: Started SelectChannelConnector@0.0.0.0:8080 13 Jan 20, 2016 1:57:52 PM winstone.Logger logInternal 14 INFO: Winstone Servlet Engine v2.0 running: controlPort=disabled 15 Jan 20, 2016 1:57:52 PM jenkins.InitReactorRunner$1 onAttained 16 INFO: Started initialization 17 Jan 20, 2016 1:57:52 PM jenkins.InitReactorRunner$1 onAttained 18 INFO: Listed all plugins 19 Jan 20, 2016 1:57:53 PM jenkins.InitReactorRunner$1 onAttained 20 INFO: Prepared all plugins 21 Jan 20, 2016 1:57:53 PM jenkins.InitReactorRunner$1 onAttained 22 INFO: Started all plugins 23 Jan 20, 2016 1:57:53 PM jenkins.InitReactorRunner$1 onAttained 24 INFO: Augmented all extensions 25 Jan 20, 2016 1:57:58 PM jenkins.InitReactorRunner$1 onAttained 26 INFO: Loaded all jobs 27 Jan 20, 2016 1:57:58 PM hudson.model.AsyncPeriodicWork$1 run 28 INFO: Started Download metadata 29 Jan 20, 2016 1:57:58 PM hudson.model.AsyncPeriodicWork$1 run 30 INFO: Finished Download metadata. 2 ms 31 Jan 20, 2016 1:57:59 PM org.jenkinsci.main.modules.sshd.SSHD start 32 INFO: Started SSHD at port 34811 33 Jan 20, 2016 1:57:59 PM jenkins.InitReactorRunner$1 onAttained 34 INFO: Completed initialization 35 Jan 20, 2016 1:57:59 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh 36 INFO: Refreshing org.springframework.web.context.support.StaticWebApplicationContext@6ddaa30c: display name [Root WebApplicationContext]; startup date [Wed Jan 20 13:57:59 CST 2016]; root of context hierarchy 37 Jan 20, 2016 1:57:59 PM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory 38 INFO: Bean factory for application context [org.springframework.web.context.support.StaticWebApplicationContext@6ddaa30c]: org.springframework.beans.factory.support.DefaultListableBeanFactory@17cfc9f4 39 Jan 20, 2016 1:57:59 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons 40 INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@17cfc9f4: defining beans [authenticationManager]; root of factory hierarchy 41 Jan 20, 2016 1:57:59 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh 42 INFO: Refreshing org.springframework.web.context.support.StaticWebApplicationContext@574f6e10: display name [Root WebApplicationContext]; startup date [Wed Jan 20 13:57:59 CST 2016]; root of context hierarchy 43 Jan 20, 2016 1:57:59 PM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory 44 INFO: Bean factory for application context [org.springframework.web.context.support.StaticWebApplicationContext@574f6e10]: org.springframework.beans.factory.support.DefaultListableBeanFactory@1006f1b7 45 Jan 20, 2016 1:57:59 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons 46 INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1006f1b7: defining beans [filter,legacy]; root of factory hierarchy 47 Jan 20, 2016 1:57:59 PM jenkins.InitReactorRunner$1 onAttained 48 INFO: Started initialization 49 Jan 20, 2016 1:57:59 PM jenkins.InitReactorRunner$1 onAttained 50 INFO: Listed all plugins 51 Jan 20, 2016 1:57:59 PM jenkins.InitReactorRunner$1 onAttained 52 INFO: Prepared all plugins 53 Jan 20, 2016 1:57:59 PM jenkins.InitReactorRunner$1 onAttained 54 INFO: Started all plugins 55 Jan 20, 2016 1:57:59 PM jenkins.InitReactorRunner$1 onAttained 56 INFO: Augmented all extensions 57 Jan 20, 2016 1:57:59 PM jenkins.InitReactorRunner$1 onAttained 58 INFO: Loaded all jobs 59 Jan 20, 2016 1:57:59 PM jenkins.InitReactorRunner$1 onAttained 60 INFO: Completed initialization 61 Jan 20, 2016 1:57:59 PM hudson.WebAppMain$3 run 62 INFO: Jenkins is fully up and running
之所以可以直接java -jar jenkins.war运行,从这个启动日志中可以看到,是因为jenkins内部集成了jetty这个web服务程序,正如spring-boot的框架,默认集成Tomcat服务程序一样。
jenkins的启动后,默认http://localhost:8080就可以打开查看web UI了,易用就体现在所有的相关配置都在web ui上完成。免除对命令行不习惯的用户的烦恼,也不需要这里配置一点,哪里配置一点的脑裂痛苦。还有,也可以自己设置选定的端口号,这样就可以: java -jar jenkins.war --httpPort=8081 , jenkins有很多启动配置选项,可以通过--help查看:
1 [root@CloudGame jenkins]# java -jar jenkins.war --help 2 Running from: /home/webWps/jenkins/jenkins.war 3 webroot: $user.home/.jenkins 4 Jenkins Continuous Integration Engine 1.644 5 Usage: java -jar jenkins.war [--option=value] [--option=value] 6 7 Options: 8 --extractedFilesFolder = folder where extracted files are to be located. Default is the temp folder 9 --daemon = fork into background and run as daemon (Unix only) 10 --config = load configuration properties from here. Default is ./winstone.properties 11 --prefix = add this prefix to all URLs (eg http://localhost:8080/prefix/resource). Default is none 12 --commonLibFolder = folder for additional jar files. Default is ./lib 13 14 --logfile = redirect log messages to this file 15 --logThrowingLineNo = show the line no that logged the message (slow). Default is false 16 --logThrowingThread = show the thread that logged the message. Default is false 17 --debug = set the level of debug msgs (1-9). Default is 5 (INFO level) 18 19 --httpPort = set the http listening port. -1 to disable, Default is 8080 20 --httpListenAddress = set the http listening address. Default is all interfaces 21 --httpDoHostnameLookups = enable host name lookups on incoming http connections (true/false). Default is false 22 --httpKeepAliveTimeout = how long idle HTTP keep-alive connections are kept around (in ms; default 5000)? 23 --httpsPort = set the https listening port. -1 to disable, Default is disabled 24 if neither --httpsCertificate nor --httpsKeyStore are specified, 25 https is run with one-time self-signed certificate. 26 --httpsListenAddress = set the https listening address. Default is all interfaces 27 --httpsDoHostnameLookups = enable host name lookups on incoming https connections (true/false). Default is false 28 --httpsKeepAliveTimeout = how long idle HTTPS keep-alive connections are kept around (in ms; default 5000)? 29 --httpsKeyStore = the location of the SSL KeyStore file. 30 --httpsKeyStorePassword = the password for the SSL KeyStore file. Default is null 31 --httpsCertificate = the location of the PEM-encoded SSL certificate file. 32 (the one that starts with '-----BEGIN CERTIFICATE-----') 33 must be used with --httpsPrivateKey. 34 --httpsPrivateKey = the location of the PEM-encoded SSL private key. 35 (the one that starts with '-----BEGIN RSA PRIVATE KEY-----') 36 --httpsKeyManagerType = the SSL KeyManagerFactory type (eg SunX509, IbmX509). Default is SunX509 37 --spdy = Enable SPDY. See http://wiki.eclipse.org/Jetty/Feature/NPN 38 --ajp13Port = set the ajp13 listening port. -1 to disable, Default is disabled 39 --ajp13ListenAddress = set the ajp13 listening address. Default is all interfaces 40 --controlPort = set the shutdown/control port. -1 to disable, Default disabled 41 42 --handlerCountStartup = set the no of worker threads to spawn at startup. Default is 5 43 --handlerCountMax = set the max no of worker threads to allow. Default is 40 44 --handlerCountMaxIdle = set the max no of idle worker threads to allow. Default is 5 45 46 --sessionTimeout = set the http session timeout value in minutes. Default to what webapp specifies, and then to 60 minutes 47 --mimeTypes=ARG = define additional MIME type mappings. ARG would be EXT=MIMETYPE:EXT=MIMETYPE:... 48 (e.g., xls=application/vnd.ms-excel:wmf=application/x-msmetafile) 49 --maxParamCount=N = set the max number of parameters allowed in a form submission to protect 50 against hash DoS attack (oCERT #2011-003). Default is 10000. 51 --usage / --help = show this message 52 --version = show the version and quit 53 54 Security options: 55 --realmClassName = Set the realm class to use for user authentication. Defaults to ArgumentsRealm class 56 57 --argumentsRealm.passwd.<user> = Password for user <user>. Only valid for the ArgumentsRealm realm class 58 --argumentsRealm.roles.<user> = Roles for user <user> (comma separated). Only valid for the ArgumentsRealm realm class 59 60 --fileRealm.configFile = File containing users/passwds/roles. Only valid for the FileRealm realm class 61 62 Access logging: 63 --accessLoggerClassName = Set the access logger class to use for user authentication. Defaults to disabled 64 --simpleAccessLogger.format = The log format to use. Supports combined/common/resin/custom (SimpleAccessLogger only) 65 --simpleAccessLogger.file = The location pattern for the log file(SimpleAccessLogger only)