git - Git 使用 jenkins 管道拉取远程服务器
问题描述
我有这个用于 git checkout 阶段,它工作正常
checkout([$class: 'GitSCM',
branches: [[name: "*/master" ]],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'LocalBranch', localBranch: "**"]],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: env.GIT_CREDS, url: env.GIT_REPO]]
])
我正在尝试配置 jenkins 作业(使用 jenkins 管道)以使用 sshagent 在远程服务器上执行git pull我 需要使用管道中为远程服务器上的 git pull 定义的GIT_CREDS需要类似:
sh "ssh ubuntu@$Ip 'git pull'"
使用GIT_CREDS和GIT_REPO 环境变量
有人可以帮我解决这个问题吗
解决方案
只需使用 git
git(
url: 'git@git.com:YourGitRepo.git',
credentialsId: '5ef933f28-bdb2-0563-bfc7-b460490262735', // found here http://jenkinsURL:8080/credentials/
branch: 'master'
)
它在内部使用 ssh。
希望能帮助到你 :)
推荐阅读
- python - Python-can - can.Logger 监听器问题
- android - Android Studio 谷歌地图无法加载
- html - 如何从我的主域的任何子域提供相同的静态内容?
- c++ - 类内的模板方法返回一个未定义的引用
- node.js - 有没有办法在node.js中使用带有读取流的ffprobe(fluent-ffmpeg)输入?
- firebase - 通过 #onNewToken 和 #getToken 检索的令牌之间的区别
- amazon-web-services - Amazon SageMaker:客户错误:二进制文本分类的训练未成功完成
- javascript - 由 js 发出的 php 文件上传信号
- mysql - 如何在 python 3 中将类对象列表“保存”到我的程序中?
- c# - 来自 EF SQL 的自定义 IQueryable 用于 Azure 移动应用服务