环境:
debian45 3.16.0-4-amd64
jenkins2.66
jdk:java version 1.8.0_131
jenkins安装:
去jenkins的官网查看(针对一切不懂的东西官方文档永远是必需品)
http://pkg.jenkins-ci.org/debian/
This is the Debian package repository of Jenkins to automate installation and upgrade. To use this repository, first add the key to your system:
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
Then add the following entry in your /etc/apt/sources.list:
deb https://pkg.jenkins.io/debian binary/
Update your local package index, then finally install Jenkins:
sudo apt-get update sudo apt-get install jenkins
JDK的安装
sudo echo “deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main“ >> /etc/apt/sources.list
sudo echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main” >>/ept/apt/sources.list
sudo apt-cacehe search java (找到java的1.8的)
oracle-java8-installer - Oracle Java(TM) Development Kit (JDK) 8
sudo apt-get install -y oracle-java8-installer
配置jenkins的环境
参考: 烂泥行天下的博客
配置jenkins加载git的分支构建
创建一个自由风格的jenkins项目
下载git的插件(我是关于git的插件都下载了)反正以后可以研究用途
系统管理->管理插件->可选插件-->search (git)
点击安装即可
配置git的基于分支的构建
然后点击构建
构建jobs:
/home/jenkins/ops/jobs
构建代码存放位置:
/home/jenkins/ops/workspace
上述的环境需要自己根据自己的磁盘配置目录
/etc/default/jenkins 配置
cat /etc/default/jenkins |grep -v -E "^#|^$"
NAME=jenkins #jenkins的变量
JAVA=/usr/bin/java #java的路径
JAVA_ARGS="-Djava.awt.headless=true"
PIDFILE=/home/jenkins/ops/jenkins_log/jenkins.pid #jenkins的pid文件
JENKINS_USER=ops #jenkins的启动用户
JENKINS_GROUP=ops #jenkins的启动用户的属主
JENKINS_WAR=/usr/share/$NAME/$NAME.war #jenkins的war包存放位置
JENKINS_HOME=/home/jenkins/ops #jenkins的主目录
RUN_STANDALONE=true
JENKINS_LOG=/home/jenkins/ops/jenkins_log/jenkins.log #jenkins的日志文件
MAXOPENFILES=8192
HTTP_PORT=8090 #jenkina启动的占用端口
PREFIX=/$NAME #PREFIX
JENKINS_ARGS="--webroot=/home/jenkins/ops/cache/war --httpPort=$HTTP_PORT" #启动命令的方式
注意:
当要改变jenkins的主目录的时候,直接吧 /var/lib/jenkins整个copy到新主目录,授权给jenkins的用户权限,即可
/etc/init.d/jenkins restart
如果遇到错误,查看
/home/jenkins/ops/jenkins_log/jenkins.log
日志文件查找解决方案
/apt/sources.list