[英]Copy file from Jenkins master to slave in Pipeline
I have some windows slave at my Jenkins so I need to copy file to them in pipeline.我的 Jenkins 有一些 windows 奴隶,所以我需要在管道中将文件复制到他们。 I heard about Copy To Slave and Copy Artifact plugins, but they doesn't have pipeline syntax manual.
我听说过 Copy To Slave 和 Copy Artifact 插件,但它们没有管道语法手册。 So I don't know how to use them in pipeline.
所以我不知道如何在管道中使用它们。
Direct copy doesn't work.直接复制不行。
def inputFile = input message: 'Upload file', parameters: [file(name: 'parameters.xml')]
new hudson.FilePath(new File("${ENV:WORKSPACE}\\parameters.xml")).copyFrom(inputFile)
This code returns and error:此代码返回错误:
Caused: java.io.IOException: Failed to copy /var/lib/jenkins/jobs/_dev/jobs/(TEST)job/builds/107/parameters.xml to d:\Jenkins\workspace\_dev\(TEST)job\parameters.xml
Is there any way to copy file from master to slave in Jenkins Pipeline?有没有办法在 Jenkins 管道中将文件从主机复制到从机?
As I understand copyFrom
is executed on your Windows node, therefore the source path is not accessible. 据我了解,
copyFrom
是在Windows节点上执行的,因此无法访问源路径。
I think you want to look into the stash
/ unstash
steps ( Jenkins Pipeline: Basic Steps ), which work across different nodes. 我认为您想研究
stash
/ unstash
stash
步骤( Jenkins Pipeline:基本步骤 ),该步骤可在不同节点上工作。 Also this example might be helpful. 同样,此示例可能会有所帮助。
Pipeline DSL context runs on master
node even that your write node('someAgentName')
in your pipeline. 管道DSL上下文在
master
节点上运行,即使您在管道中的写入node('someAgentName')
也是如此。
archive()
and sh("wget $url")
will be helpful. archive()
和sh("wget $url")
会有所帮助。 If the requirement is to copy an executable to the test slave and to publish the test results, this is easy to do without the Copy to Slave plugin.如果需要将可执行文件复制到测试从站并发布测试结果,则无需复制到从站插件即可轻松完成。
A shared folder should be created on each test slave (normal Windows shared folder).应该在每个测试从站上创建一个共享文件夹(普通的 Windows 共享文件夹)。
After build: Build script copies the executable to the shared directory on each slave.构建后:构建脚本将可执行文件复制到每个从站上的共享目录。 A simple batch script using
copy
command is sufficient for this.使用
copy
命令的简单批处理脚本就足够了。
stage ('Copy to slaves') {
steps {
bat 'call "copy-to-slave.bat"'
}
}
During test: The test script copies the executable to another directory and runs it.在测试期间:测试脚本将可执行文件复制到另一个目录并运行它。
After test: Post-build action "Publish Robot Framework test results" can be used to report the test results.测试后:构建后动作“发布机器人框架测试结果”可用于报告测试结果。 It is not necessary to copy the test result files back to the master first.
无需先将测试结果文件复制回主站。
I recommend on Pipeline: Phoenix AutoTest
plugin我在
Pipeline: Phoenix AutoTest
插件
Jenkins plugin website: https://plugins.jenkins.io/phoenix-autotest/#documentation Jenkins插件网址: https://plugins.jenkins.io/phoenix-autotest/#documentation
GitHub repository of plugin: https://github.com/jenkinsci/phoenix-autotest-plugin GitHub 插件仓库: https://github.com/jenkinsci/phoenix-autotest-plugin
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.