nicenote/docs/tools/jenkins.md
2024-01-18 16:29:26 +08:00

97 lines
1.7 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
nav:
title: 工具
path: /tools
group:
title: 工具
order: 9
---
# Jenkins
## 安装 java 环境
### 查看 jdk 列表
- yum list java\*
### 安装 jdk
- yum install java-1.8.0-openjdk-devel.x86_64
or
- yum install fontconfig java-17-openjdk
### 检查是否成功
- java -version
### 修改默认的 java 版本
- alternatives --config java
## 安装 Jenkins 包
### ① 下载依赖
- sudo wget -O /etc/yum.repos.d/jenkins.repo <https://pkg.jenkins.io/redhat-stable/jenkins.repo>
### ② 导入密钥
- sudo rpm --import <https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key>
### ③ 开始安装
- yum install jenkins #等待安装时间较长,约 25min
### ④ 查看 Jenkins 安装路径
- rpm -ql jenkins
### ⑥ 启动 Jenkins
- java -jar /usr/lib/jenkins/jenkins.war
- nohup java -jar /usr/lib/jenkins/jenkins.war &
- 若端口被占用则执行java -jar /usr/lib/jenkins/jenkins.war --ajp13Port=-1 --httpPort=8899
### 修改配置文件
如果想修改端口号可以找到以下文件:
- vim /etc/sysconfig/jenkins
修改为 JENKINS_PORT="${port}"
### ⑦ 查看端口
- netstat -ntlp
- netstat -tln | grep 8088
- sudo lsof -i:8088
### ⑧ 关闭端口
- sudo kill -9 8088
### ⑨ 查看磁盘和分区情况
- df -h
## \*\* 问题解决
### 1、No valid crumb was included in the request
- 在 jenkins 的 Configure Global Security 下 , 取消“防止跨站点请求伪造Prevent Cross Site Request Forgery exploits”的勾选。
### 2、git 找不到
- yum install git
- whereis git 将路径放在 config tools git 配置里
### 3、jenkins 打开项目构建很卡
- 凭证 - 配置全局凭证id_rsa
### 4、无法使用 node 等工具
- ① source /etc/profile
- ② 安装全局工具插件