一. GitLab 配置 SSH 秘钥并保存
a. 秘钥为 Jenkins 服务的公钥
二. 创建 Jenkins 全局凭据
a. Dashboard--凭据--系统--全局凭据 (unrestricted)--添加凭据 1. 类型:SSH
2. ID:自动生成
3. 描述:自定义
4. Username:Jenkins 服务器系统用户
5. Private Key:Jenkins 服务器系统私钥
b. 保存并记录生成的 ID:
c. 创建 Pipeline 项目
d. 配置流程
node {
stage('Preparation') {
// 通过 Jenkins 私钥的方式去验证 gitlab
git credentialsId: '14567b2c-e690-4d96-84a8-b276cefe53d8', url: '[email protected]:root/k8s-demo-docker.git'
}
}
e. 保存构建测试