Jenkins安装+配置Git +Maven的自动化构建(上)

背景

jenkins是一个广泛用于持续构建的可视化web工具,持续构建说得更直白点,就是各种项目的”自动化”编译、打包、分发部署。jenkins可以很好的支持各种语言(比如:java, c#, php等)的项目构建,也完全兼容ant、maven、gradle等多种第三方构建工具,同时跟svn、git能无缝集成,也支持直接与知名源代码托管网站,比如github、bitbucket直接集成。

jenkins官网地址为https://jenkins.io/,jenkins本身是用java语言开发的,所以安装jenkins的机器至少要有jdk,另外建议git、ant、maven、gradle、groovy等工具也一并安装好,方便与这些构建工具集成。

安装jenkins前准备

说明

因为使用到git和maven进行项目的自动化构建,所以1.安装jdk(建议下载jdk1.8);2.安装git;3.安装maven;4安装tomcat。着重介绍下安装jdk,maven和git不介绍了,网上搜一大堆,写着累啊。。。

安装jdk1.8

1.切换到所需的安装目录。键入:
cd /usr/java/
2.将 .tar.gz 档案二进制文件移到当前目录。
3.解压缩 tarball 并安装 Java
tar zxvf jre-8u144-linux-x64.tar.gz
Java 文件将安装在当前目录中名为 jre1.8.0_144 的目录内。在本示例中,Java 将安装在 /usr/java/jre1.8.0_144 目录中。当安装完成时,您将看到 Done(完成)字样。
4.如果要节省磁盘空间,请删除 .tar.gz 文件。*

配置jdk

编辑profile文件,配置环境变量

vi  /etc/profile

下面配置内容放在文件内容最上方即可

export JAVA_HOME=/usr/java/jre1.8.0_144
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$PATH

接着使用source命令应用修改

source /etc/profile

最后校验安装是否正确

[root@root ~]# java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

git安装

安装说明:https://git-scm.com/book/zh/v2/%E8%B5%B7%E6%AD%A5-%E5%AE%89%E8%A3%85-Git

maven安装

安装说明:https://maven.apache.org/install.html

安装和启动

方式1:

这是官网介绍的方式,直接从 http://mirrors.jenkins.io/war/latest/jenkins.war 最新war包,终端进入war包目录,执行

 java -jar jenkins.war --httpPort=8080

再在浏览器打开地址 http://localhost:8080.根据介绍进行安装。

方式2:

下载war包,然后直接丢在tomcat的webapps,然后启动tomcat 就完成Jenkins 的安装了。这种是我感觉最方便的方式。

安装过程中遇到的问题

原先安装的jdk是1.7的,由于版本原因不能加载class jenkins.util.SystemProperties 导致报错

九月 26, 2017 6:33:44 下午 org.apache.catalina.core.StandardContext listenerStart
严重: 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:3200)
    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.run(FutureTask.java:262)
    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:744)    

参考:徐刘根的专栏 | 菩提树下的杨过.Net

发布了99 篇原创文章 · 获赞 52 · 访问量 32万+
展开阅读全文

Jenkins构建maven项目失败报错:

10-12

ERROR: Failed to parse POMs hudson.util.IOException2: Failed to access https://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/ViewProductDetail-Start?ProductRef=C:\Jdk1.7 at hudson.tools.JDKInstaller.locateStage1(JDKInstaller.java:352) at hudson.tools.JDKInstaller.locate(JDKInstaller.java:298) at hudson.tools.JDKInstaller.performInstallation(JDKInstaller.java:121) at hudson.tools.InstallerTranslator.getToolHome(InstallerTranslator.java:61) at hudson.tools.ToolLocationNodeProperty.getToolHome(ToolLocationNodeProperty.java:106) at hudson.tools.ToolInstallation.translateFor(ToolInstallation.java:149) at hudson.model.JDK.forNode(JDK.java:111) at hudson.model.AbstractBuild.getEnvironment(AbstractBuild.java:745) at hudson.maven.MavenModuleSetBuild.getEnvironment(MavenModuleSetBuild.java:157) at hudson.maven.MavenModuleSetBuild$RunnerImpl.doRun(MavenModuleSetBuild.java:573) at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:423) at hudson.model.Run.run(Run.java:1362) at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:467) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:145) Caused by: java.net.UnknownHostException: cds.sun.com at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1676) at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1674) at java.security.AccessController.doPrivileged(Native Method) at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1672) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1245) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254) at hudson.tools.JDKInstaller.locateStage1(JDKInstaller.java:340) ... 14 more Caused by: java.net.UnknownHostException: cds.sun.com at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:579) at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:625) at sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:160) at sun.net.NetworkClient.doConnect(NetworkClient.java:180) at sun.net.www.http.HttpClient.openServer(HttpClient.java:432) at sun.net.www.http.HttpClient.openServer(HttpClient.java:527) at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:275) at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:371) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:933) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1301) at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:2691) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getHeaderField(HttpsURLConnectionImpl.java:291) at hudson.tools.JDKInstaller.locateStage1(JDKInstaller.java:334) ... 14 more Finished: FAILURE 好像是连不上cds.sun.com的原因, 不理解怎么改 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 技术黑板 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览