我已经开始学习Jenkins了,这里有一个入门任务(。
我在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 {
agent any
stage ('Clone the git project'){
step{
git 'https://github.com/my_prod’
}
}
}
然后呢?
我读过文档,但不知道如何正确操作。
看起来您同时使用了这两个Linux服务器。在复制文件之前,请确保您的Jenkins服务器可以访问您要将文件复制到的vm。如果没有,请按照〔两台服务器之间的ssh〕[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/