天天看点

Jenkins + Git + Maven + tomcat集成环境(Jenkins 安装)

Linux(Ubuntu16.04)下安装Jenkins

jenkins官网https://pkg.jenkins.io

这是Jenkins的Debian软件包存储库,用于自动安装和升级。要使用此存储库,请先将密钥添加到系统中:

wget -q -O  - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add  -
      

然后追加下列内容到 /etc/apt/sources.list文件中(apt命令下载时会找下面的地址)

deb https://pkg.jenkins.io/debian-stable binary /       
即: sudo sh -c  'echo deb https://pkg.jenkins.io/debian-stable binary /  >>  /etc/apt/sources.list'      

更新您的本地包索引,然后最后安装Jenkins:

sudo apt-get update 
sudo apt-get install jenkins
      

 安装jenkins后

sudo /etc/init.d/jenkins start   //jenkins服务开启 注意端口号是否被占用(8080)
sudo /etc/init.d/jenkins status   //查看jenkins服务开启状态
sudo /etc/init.d/jenkins stop   //jenkins服务关闭
           

查看进程中的jenkins

ps aux | grep jenkins
           

jenkins的日志(/var/log/jenkins/jenkins.log)

more /var/log/jenkins/jenkins.log
           

启动jenkins 若端口被占用时,需要关闭jenkins服务,更改被占用的端口(一般是改tomcat的)

再开启jenkins服务,查看下日志是否启动成功!

7.进入选择插件安装界面,选择第一个(Install suggested plugins)

  

Jenkins + Git + Maven + tomcat集成环境(Jenkins 安装)

  

Jenkins + Git + Maven + tomcat集成环境(Jenkins 安装)

  8.插件安装完成之后,需要创建第一个用户

  

Jenkins + Git + Maven + tomcat集成环境(Jenkins 安装)

  9.创建用户之后,就可以使用jenkins了

  

Jenkins + Git + Maven + tomcat集成环境(Jenkins 安装)
Jenkins + Git + Maven + tomcat集成环境(Jenkins 安装)
Jenkins + Git + Maven + tomcat集成环境(Jenkins 安装)
Jenkins + Git + Maven + tomcat集成环境(Jenkins 安装)

附:Tomcat下部署Jenkins (win7)

官网下载http://jenkins-ci.org/

直接下载jenkins.war,网上说放到tomcat的webapps下,直接启动tomcat便可,但是访问

http://localhost:8080/jenkins 出现了以下问题,且出现类似于下面的截图(网上的图),jenkins启动失败!

Jenkins + Git + Maven + tomcat集成环境(Jenkins 安装)

注:我使用的是apache-tomcat-7.0.75,jekins是2.56版本,jdk是1.8.0_131

四月 25, 2017 10:25:01 下午 org.apache.catalina.core.StandardContext listenerStart
SEVERE: Error configuring application listener of class jenkins.util.SystemProperties
java.lang.UnsupportedClassVersionError: jenkins/util/SystemProperties : Unsupported major.minor version 52.0 (unable to load class jenkins.util.SystemProperties)
	at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:3209)
	at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:1373)
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1861)
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1735)
	at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:504)
	at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:486)
	at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:113)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5034)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5634)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
	at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1092)
	at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1984)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
	at java.util.concurrent.FutureTask.run(FutureTask.java:166)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:722)

四月 25, 2017 10:25:01 下午 org.apache.catalina.core.StandardContext listenerStart
SEVERE: Error configuring application listener of class hudson.WebAppMain
java.lang.UnsupportedClassVersionError: hudson/WebAppMain : Unsupported major.minor version 52.0 (unable to load class hudson.WebAppMain)
	at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:3209)
	at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:1373)
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1861)
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1735)
	at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:504)
	at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:486)
	at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:113)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5034)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5634)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
	at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1092)
	at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1984)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
	at java.util.concurrent.FutureTask.run(FutureTask.java:166)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:722)

四月 25, 2017 10:25:01 下午 org.apache.catalina.core.StandardContext listenerStart
SEVERE: Error configuring application listener of class jenkins.JenkinsHttpSessionListener
java.lang.UnsupportedClassVersionError: jenkins/JenkinsHttpSessionListener : Unsupported major.minor version 52.0 (unable to load class jenkins.JenkinsHttpSessionListener)
	at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:3209)
	at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:1373)
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1861)
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1735)
	at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:504)
	at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:486)
	at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:113)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5034)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5634)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
	at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1092)
	at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1984)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
	at java.util.concurrent.FutureTask.run(FutureTask.java:166)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:722)

四月 25, 2017 10:25:01 下午 org.apache.catalina.core.StandardContext listenerStart
SEVERE: Skipped installing application listeners due to previous error(s)
四月 25, 2017 10:25:01 下午 org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
四月 25, 2017 10:25:01 下午 org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
四月 25, 2017 10:25:01 下午 org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', '[email protected]')
四月 25, 2017 10:30:27 下午 org.apache.catalina.core.StandardContext listenerStart
SEVERE: Error configuring application listener of class jenkins.util.SystemProperties
java.lang.UnsupportedClassVersionError: jenkins/util/SystemProperties : Unsupported major.minor version 52.0 (unable to load class jenkins.util.SystemProperties)
	at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:3209)
	at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:1373)
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1861)
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1735)
	at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:504)
	at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:486)
	at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:113)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5034)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5634)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
	at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1092)
	at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1984)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
	at java.util.concurrent.FutureTask.run(FutureTask.java:166)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:722)

四月 25, 2017 10:30:27 下午 org.apache.catalina.core.StandardContext listenerStart
SEVERE: Error configuring application listener of class hudson.WebAppMain
java.lang.UnsupportedClassVersionError: hudson/WebAppMain : Unsupported major.minor version 52.0 (unable to load class hudson.WebAppMain)
	at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:3209)
	at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:1373)
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1861)
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1735)
	at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:504)
	at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:486)
	at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:113)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5034)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5634)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
	at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1092)
	at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1984)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
	at java.util.concurrent.FutureTask.run(FutureTask.java:166)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:722)

四月 25, 2017 10:30:27 下午 org.apache.catalina.core.StandardContext listenerStart
SEVERE: Error configuring application listener of class jenkins.JenkinsHttpSessionListener
java.lang.UnsupportedClassVersionError: jenkins/JenkinsHttpSessionListener : Unsupported major.minor version 52.0 (unable to load class jenkins.JenkinsHttpSessionListener)
	at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:3209)
	at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:1373)
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1861)
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1735)
	at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:504)
	at o
           

网上找了些博客资料如下:

http://www.mkyong.com/java/java-unsupported-major-minor-version-51-0/ 大概说的是major.minor version 52.0 = JDK 1.8 / 8 (可我系统java就是1.8)

结果网上说可以用:java -jar jenkins.war 启动方式,最终启动了

D:\Tools>java -jar jenkins.war
Running from: D:\Tools\jenkins.war
webroot: $user.home/.jenkins
[33m四月 26, 2017 8:28:16 下午 Main deleteWinstoneTempContents
警告: Failed to delete the temporary Winstone file C:\Users\ADMINI~1\AppData\Local\Temp\winstone\jenkins.war
[0m四月 26, 2017 8:28:16 下午 org.eclipse.jetty.util.log.JavaUtilLog info
信息: Logging initialized @999ms
四月 26, 2017 8:28:16 下午 winstone.Logger logInternal
信息: Beginning extraction from war file
[33m四月 26, 2017 8:28:16 下午 org.eclipse.jetty.util.log.JavaUtilLog warn
警告: Empty contextPath
[0m四月 26, 2017 8:28:16 下午 org.eclipse.jetty.util.log.JavaUtilLog info
信息: jetty-9.2.z-SNAPSHOT
四月 26, 2017 8:28:18 下午 org.eclipse.jetty.util.log.JavaUtilLog info
信息: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
Jenkins home directory: C:\Users\Administrator\.jenkins found at: $user.home/.jenkins
四月 26, 2017 8:28:19 下午 org.eclipse.jetty.util.log.JavaUtilLog info
信息: Started [email protected]{/,file:/C:/Users/Administrator/.jenkins/war/,AVAILABLE}{C:\Users\Administrator\.jenkins\war}
四月 26, 2017 8:28:19 下午 org.eclipse.jetty.util.log.JavaUtilLog info
信息: Started [email protected]{HTTP/1.1}{0.0.0.0:8080}
四月 26, 2017 8:28:19 下午 org.eclipse.jetty.util.log.JavaUtilLog info
信息: Started @3399ms
四月 26, 2017 8:28:19 下午 winstone.Logger logInternal
信息: Winstone Servlet Engine v2.0 running: controlPort=disabled
四月 26, 2017 8:28:19 下午 jenkins.InitReactorRunner$1 onAttained
信息: Started initialization
四月 26, 2017 8:28:19 下午 jenkins.InitReactorRunner$1 onAttained
信息: Listed all plugins
四月 26, 2017 8:28:21 下午 jenkins.InitReactorRunner$1 onAttained
信息: Prepared all plugins
四月 26, 2017 8:28:21 下午 jenkins.InitReactorRunner$1 onAttained
信息: Started all plugins
四月 26, 2017 8:28:21 下午 jenkins.InitReactorRunner$1 onAttained
信息: Augmented all extensions
四月 26, 2017 8:28:22 下午 jenkins.InitReactorRunner$1 onAttained
信息: Loaded all jobs
四月 26, 2017 8:28:22 下午 hudson.model.AsyncPeriodicWork$1 run
信息: Started Download metadata
四月 26, 2017 8:28:22 下午 hudson.model.AsyncPeriodicWork$1 run
信息: Finished Download metadata. 8 ms
四月 26, 2017 8:28:22 下午 jenkins.InitReactorRunner$1 onAttained
信息: Completed initialization
四月 26, 2017 8:28:23 下午 org.springframework.context.support.AbstractApplicationContext prepareRefresh
信息: Refreshing org.springframework.web.context.support.StaticWebApplicationContext@2a57a20c: display name [Root WebApplicationContext]; startup date [Wed Apr 26
20:28:23 CST 2017]; root of context hierarchy
四月 26, 2017 8:28:23 下午 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
信息: Bean factory for application context [org.springframework.web.context.support.StaticWebApplicationContext@2a57a20c]: org.springframework.beans.factory.suppor
[email protected]
四月 26, 2017 8:28:23 下午 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@24edf948: defining beans [authenticationManager]; root o
f factory hierarchy
四月 26, 2017 8:28:23 下午 org.springframework.context.support.AbstractApplicationContext prepareRefresh
信息: Refreshing org.springframework.web.context.support.StaticWebApplicationContext@a435e2d: display name [Root WebApplicationContext]; startup date [Wed Apr 26 2
0:28:23 CST 2017]; root of context hierarchy
四月 26, 2017 8:28:23 下午 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
信息: Bean factory for application context [org.springframework.web.context.support.StaticWebApplicationContext@a435e2d]: org.springframework.beans.factory.support
[email protected]
四月 26, 2017 8:28:23 下午 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@d091d78: defining beans [filter,legacy]; root of factory
 hierarchy
四月 26, 2017 8:28:23 下午 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:

8c04dcc0e6f74b99a4bb60034af35fbb

This may also be found at: C:\Users\Administrator\.jenkins\secrets\initialAdminPassword

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

四月 26, 2017 8:28:29 下午 hudson.model.UpdateSite updateData
信息: Obtained the latest update center data file for UpdateSource default
四月 26, 2017 8:28:29 下午 hudson.WebAppMain$3 run
信息: Jenkins is fully up and running
           

直接访问http://localhost:8080/jenkins 又报了错

HTTP ERROR 404

Problem accessing /jenkins. Reason:

    Not Found
Powered by Jetty://
           

结果搜索后发现各种说法,还是没解决!

然后通过直接访问http://localhost:8080/居然出现了jenkins的配置页面,结果跳过安装插件等配置页面自动跳转到了首页

Win7上这也算是稀里糊涂的部署启动完毕...-_-||

继续阅读