jenkins传统部署
总览:
版本说明:
- tomcat 8.5.55
- jdk 1.8
- jenkins 2.222.4
### 目录
- jdk=/data/jdk8
- tomcat=/data/jenkins/tomcat8
- jenkins=/data/jenkins
参考docker-compose部署方式(已放弃)
网址:<https://www.wangairui.com/docs/docker/docker-1c30jstdfrft8>
### 1 war 下载部署
官网:<https://www.jenkins.io/zh/download/>
左边是半年更新一次稳定包 右边是一周一次最新包 我就用右边的了
wget http://mirrors.jenkins.io/war-stable/2.164.3/jenkins.war
2020年12月29日最新版本
wget http://mirrors.jenkins.io/war/2.272/jenkins.war
```yaml
mkdir /data/jenkins/
wget http://mirrors.jenkins.io/war/latest/jenkins.war
```
### 2 jdk 部署 我用之前下载的包`前提登录oracle中国区账户 否则下载不了`
下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
```yaml
cd /data/jenkins
tar xf jdk-8u241-linux-x64.tar..gz
mv jdk1.8.0_241/ ../jdk8
```
.bak 意思备份 $a 最后一行,a追加 \n换行
```yaml
sed -i.bak '$a export JAVA_HOME=/data/jdk8\nexport JRE_HOME=${JAVA_HOME}/jre\nexport CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib\nexport PATH=${JAVA_HOME}/bin:$PATH' /etc/profile
```
```yaml
source /etc/profile
java -version
java version "1.8.0_241"
Java(TM) SE Runtime Environment (build 1.8.0_241-b07)
Java HotSpot(TM) 64-Bit Server VM (build 25.241-b07, mixed mode)
```
```yaml
sed -i.bak '$a export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/lib' /etc/profile
source /etc/profile
```
### 3 tomcat安装
参考地址:<https://www.wangairui.com/api/npt/edit/>
### 3 调试参数
#### 3.1 添加jenkins目录
在# OS specific support. $var must be set to either true or false.上面添加:export JENKINS_HOME=""
在引号中填入你的路径。
```yaml
vim /data/jenkins/tomcat8/bin/catalina.sh
export JENKINS_HOME="/data/jenkins/jenkins_home"
```
或者sed插入
```yaml
sed -i .bak'$a export JENKINS_HOME=/data/jenkins/jenkins_home' /etc/profile
```
生效配置
```yaml
source /etc/profile
```
#### 3.2 内存溢出(防止内存占用过多)
参考网址:<https://www.wangairui.com/api/npt/edit/>
```yaml
vim /data/jenkins/tomcat8/bin/catalina.sh
JAVA_OPTS='-server -Xms2024m -Xmx2024m'
```
#### 3.2 缓存优化(会在日志提示报错)
```yaml
vim /data/jenkins/tomcat8/conf/context.xml
<Resources cachingAllowed="true" cacheMaxSize="100000" ></Resources>
```
否则报错 默认是1024 设置大一点
#### 3.3 加载慢把第一行的源地址谷歌改成百度(解决:一直加载问题)
```yaml
vim /data/jenkins/jenkins_home/updates/default.json
{"connectionCheckUrl":"http://www.baidu.com/"
```
#### 3.4 Plugin仓库地址修改(解决:插件下载不成功)
```yaml
vim /data/jenkins/jenkins_home/hudson.model.UpdateCenter.xml
<?xml version='1.1' encoding='UTF-8'?>
<sites>
<site>
<id>default</id>
<url>http://mirror.xmission.com/jenkins/updates/update-center.json</url>
</site>
</sites>
```
### 4 重启脚本
<https://www.wangairui.com/api/shell/edit/>
### 5 查看管理员密码
cat /data/jenkins/jenkins_home/secrets/initialAdminPassword
- 感谢你赐予我前进的力量