从Jenkins的工作区Groovy脚本读取

从Jenkins的工作区Groovy脚本读取

本文介绍了从Jenkins的工作区Groovy脚本读取.txt文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Jenkins和groovy脚本的新手,我想读取一个.txt文件,该文件位于其中一个作业的工作空间中.我正在尝试这样做:

I am new to Jenkins and to groovy scripting, I want to read a .txt file which is located in the workspace of one of the jobs. I am trying to do this way:

myfile = Jenkins.instance.getJob('JobName').workspace.readFileFromWorkspace('file.txt');

但是会导致以下错误:

推荐答案

尝试一下:

file = new File("${Jenkins.instance.getJob('JobName').workspace}/file.txt").text

这篇关于从Jenkins的工作区Groovy脚本读取.txt文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 08:19