git - 如何使用 Jenkins 管道将文件从 Github 克隆到 VM?
问题描述
我已经开始学习 Jenkins,这是一个入门任务)。
我在 GitHub 上有一个小网站(html 和 css 文件)和一个 Linux 服务器(虚拟机)。如何将文件从 git 克隆到“/var/www/”文件夹中的虚拟机。
例如:Jenkins 服务器在 192.168.10.10 上运行,目标虚拟机在 192.168.2.30 上。
所以,首先我应该将此存储库克隆到我的代理(192.168.10.10 '/var/lib/jenkins/workspace/'),然后从那里复制到我的虚拟机?
它看起来像
pipeline {
agent any
stage ('Clone the git project'){
step{
git 'https://github.com/my_prod’
}
}
}
接着?
我已阅读文档,但无法理解如何正确执行。
解决方案
Looks like you are using both Linux servers. Before copying the files make sure your Jenkins server has access to the vm that you're copying files to. If not follow this [ssh between two servers][1] to provide the access to the Jenkins server
pipeline {
agent any
stage ('Clone the git project'){
step{
git 'https://github.com/my_prod’
script{
scp user1@remote1:/home/user1/file1.txt user2@remote2:/home/user2/file1.txt
}
}
}
}
[1]: https://www.techrepublic.com/article/how-to-copy-a-file-between-two-remote-ssh-servers/
推荐阅读
- play-json - 使用 Play JSON 派生编解码器对生成的 JSON 进行排序
- kotlin - 有没有办法限制 Corda RPC 用户可以在其节点的保险库中查看的交易数据?
- json - 使用 jq 从列表列表中获取所有值
- angular - 如何让 ng-content 选择过滤器与投影模板内容一起使用?
- reactjs - 如何在 ReactJS/HTML/CSS 网站中实现 cookie 同意并能够关闭 cookie?
- json - 需要从 shell 输出中的数组末尾删除逗号
- java - 为什么 deleteById 遵循双向方法?
- config - Flink 应用部署的 session 模式如何切换到 job 模式?
- javascript - 如何使用 JavaScript 在数组中创建 onkey up 搜索?
- ios - 在iOS中的两条线之间绘制垂直线