你这个问题通常有两种理解,我分别说明,方便对号入座:
如果你是想让 Jenkins 服务器或构建节点使用 Debian 的 apt 仓库(比如安装依赖、构建 Debian 包):
在 Jenkins 所在机器上:
sudo sed -i 's|http://deb.debian.org|https://mirrors.aliyun.com|g' /etc/apt/sources.list
sudo apt update
sh 'sudo apt-get update'
sh 'sudo apt-get install -y build-essential'
如果是私有 Debian 仓库(如 aptly、reprepro):
echo "deb http://repo.example.com/debian stable main" | sudo tee /etc/apt/sources.list.d/myrepo.list
sudo apt update
如果你是想 Jenkins 打包后上传到 Debian 仓库:
aptly repo add myrepo ./xxx.deb
aptly publish update stable
Jenkins Pipeline:
stage('Publish') {
sh '''
aptly repo add myrepo *.deb
aptly publish update stable
'''
}
如果是 在 Debian 上安装 Jenkins:
sudo apt update
sudo apt install -y jenkins
或官方源:
curl -fsSL https://pkg.jenkins.io/debian/jenkins.io.key | sudo tee \
/usr/share/keyrings/jenkins-keyring.asc > /dev/null
echo "deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian binary/" | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt update
sudo apt install -y jenkins
InRelease / Release.gpg如果你能补充一句:
你是 Jenkins 用 Debian 源,还是 Jenkins 发布 .deb 到 Debian 仓库?
我可以直接给你一套完整配置。