Jenkins

Ubuntu22.04 全程root用户

一、安装

apt-get install -y openjdk-11-jdk
# 将存储库密钥添加到系统
wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add -
# 将Debian包存储库地址附加到服务器的sources.list
echo deb http://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list
# 运行update
apt-get -y update

	# 如果上面更新报错
	apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 上面给的公钥

apt-get install -y jenkins

二、启动

systemctl start jenkins
systemctl status jenkins

# 注意防火墙
ufw allow 8080
ufw status

三、配置

# 搜8080端口修改
vim /etc/init.d/jenkins
vim /etc/default/jenkins
vim /lib/systemd/system/jenkins.service
# 重启
systemctl daemon-reload
systemctl restart jenkins
systemctl status jenkins

四、添加服务器

image-20230926153558271

  1. 安装插件Publish over ssh
  2. 如图,在系统配置里添加服务器
  3. 使用路径公钥权限报错:jenkins启动使用的是jenkins用户,无权访问/root/.ssh

五、部署脚本

  1. 工作目录
cd /var/lib/jenkins/workspace/
  1. 构建环境

Build Steps 是在部署 jenkins 的服务器上执行

posted @ 2023-09-22 14:11  anyiya  阅读(14)  评论(0编辑  收藏  举报