一、Jenkins简介
Jenkins是基于Java开发的一种持续集成工具,用于监控持续重复的工作,旨在提供一个开放易用的软件平台,它提供了数百个插件来支持构建、部署、自动化任何项目,使软件的持续集成变成可能。
我刚还换新工作,老大叫我部署Jenkins才开始接触这个,下面就聊聊我的搭建过程吧~~
二、环境部署
我是在Ubuntu18.04服务器上搭建的
- Java环境
因为Jenkins是基于Java开发的,所以一定要有Java环境
# sudo apt-get install openjdk-8-jre
# sudo apt-get install openjdk-8-jdk
# vi /etc/profile #添加环境变量
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
# source /etc/profile
- git
# sudo apt-get install git
三、安装
- 下载Jenkins
可以直接在官网上下载:https://jenkins.io/download/
也可以命令下载:
# wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add -
# sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
# sudo apt-get update
# sudo apt-get install jenkins
- 运行
# java -jar /usr/share/jenkins/jenkins.war --httpPort=80
这里我指定端口号为80,默认是8080,为什么要改是因为8080已经被其他程序占用了。启动的过程中会有admin的密码,等下登录用的(如果没有指定过JENKINS_HOME,默认应该是放在/root/.jenkins/secrets/initialAdminPassword,如果这里没有留意到后面登录的时候也会有提示的)
- Jenkins使用
Jenkins运行起来后,打开浏览器url: jenkins服务器ip,然后用admin登陆,下载一些插件。至此Jenkins就可以开始使用拉~~
(具体的使用过程我会放在下一篇详细说明)
可能会遇到的问题
Apr 26, 2019 12:55:33 PM winstone.Logger logInternal
SEVERE: Container startup failed
java.io.IOException: Failed to start Jetty
at winstone.Launcher.(Launcher.java:186)
at winstone.Launcher.main(Launcher.java:354)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at Main._main(Main.java:375)
at Main.main(Main.java:151)
Caused by: java.net.BindException: Address already in use
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:433)
at sun.nio.ch.Net.bind(Net.java:425)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:339)
at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:307)
at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:235)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.server.Server.doStart(Server.java:395)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at winstone.Launcher.(Launcher.java:184)
… 7 more
看到“Caused by: java.net.BindException: Address already in use”所以需要修改端口号
# vim /etc/default/jenkins
# port for HTTP connector (default 8080; disable with -1)
HTTP_PORT=80
来源:CSDN
作者:陈阿呆要好好测
链接:https://blog.csdn.net/weixin_43273051/article/details/90321510