[英]How to copy a workspace of a job from jenkins master to slave container and copy back from slave to master?
[英]Jenkins: Copy from build folder on master to workspace on slave
我已经在我的Jenkins实例上安装了Test Complete插件,我想将在主服务器上的build文件夹中生成的junitResult.xml复制到从服务器上的工作空间。 是否可以安全地执行此操作?
如果使用管道,则可以使用stash / ustash选项。
将junitResult.xml文件存放在主节点上,然后在另一个节点上存放到工作区。
1)安装“复制工件插件”
2)主作业发布构建步骤:归档工件junitResult.xml
3)从属作业构建步骤:从其他项目复制工件-指定项目名称,然后复制要构建的工件-junitResult.xml
如果有人对此主题感兴趣,那么我已经通过使用时髦的脚本成功完成了此工作。 就我而言(与Jenkins集成TestComplete插件),我将一个名为junitResult.xml的文件复制到了工作区。 这是秘诀:
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
FilePath getMasterLogDirectory(AbstractBuild build) throws IOException, InterruptedException {
String buildDir = build.getRootDir().getAbsolutePath();
FilePath masterLogDirectory = new FilePath(new File(buildDir + File.separator + "junitResult.xml"));
return masterLogDirectory;
}
FilePath getSlaveWorkspace(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException {
String workspacePath = build.getEnvironment(listener).get("WORKSPACE");
if (workspacePath == null) {
throw new IOException(Messages.TcTestBuilder_InternalError());
}
FilePath projectWorkspaceOnSlave = new FilePath(launcher.getChannel(), workspacePath);
projectWorkspaceOnSlave.mkdirs();
return projectWorkspaceOnSlave.absolutize();
}
def junitName = "junitResult.xml"
FilePath slaveWorkspacePath = getSlaveWorkspace(build, launcher, listener)
FilePath slaveJunitFilePath = new FilePath(slaveWorkspacePath, junitName);
getMasterLogDirectory(build).copyTo(slaveJunitFilePath )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.