文件位于/opt/apps/workspace/build32/target/site/result.htmlLinux 工作节点上。构建在/opt/apps/workspace/build32文件夹下运行。下面是我正在使用的代码片段。
if (fileExists("/opt/apps/workspace/build32/target/site/result.html")) {
echo "result.html file exist"
}
else {
echo " File does not exist"
}
def file = new File("/opt/apps/workspace/build32/target/site/result.html").collect{it}
def index = file.findIndexOf{ it ==~ /.*Result.*/ }
echo "file[index]"
Run Code Online (Sandbox Code Playgroud)
输出:
Running in /opt/apps/workspace/build32.
[pipeline] result.html file exist
[pipeline] build status UNSTABLE build message there was an error on stage Test, result.html (No such file or directory)
Run Code Online (Sandbox Code Playgroud)