如何使用Jenkins管道将文件从Github克隆到VM?
我已经开始学习詹金斯,这里是一个入门任务) 我在GitHub上有一个小网站(html和css文件)和一个Linux服务器(虚拟机)。 如何将文件从git克隆到“/var/www/”文件夹中的虚拟机 例如: Jenkins服务器运行于192.168.10.10,目标VM运行于192.168.2.30 所以,首先我应该将这个repo克隆到我的代理(192.168.10.10'/var/lib/jenkins/workspace/),然后从那里复制到我的VM 看起来像如何使用Jenkins管道将文件从Github克隆到VM?,git,jenkins,jenkins-pipeline,devops,Git,Jenkins,Jenkins Pipeline,Devops,我已经开始学习詹金斯,这里是一个入门任务) 我在GitHub上有一个小网站(html和css文件)和一个Linux服务器(虚拟机)。 如何将文件从git克隆到“/var/www/”文件夹中的虚拟机 例如: Jenkins服务器运行于192.168.10.10,目标VM运行于192.168.2.30 所以,首先我应该将这个repo克隆到我的代理(192.168.10.10'/var/lib/jenkins/workspace/),然后从那里复制到我的VM 看起来像 pipeline { age
pipeline {
agent any
stage ('Clone the git project'){
step{
git 'https://github.com/my_prod’
}
}
}
然后呢
我已经阅读了文档,但不明白如何正确地执行此操作。看起来您正在使用这两台Linux服务器。在复制文件之前,请确保Jenkins服务器可以访问要将文件复制到的vm。如果没有,请按照[ssh-between-two-server][1]提供对Jenkins服务器的访问
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/