简体   繁体   English

从 jenkins 运行代码时出现 java.io.FileNotFoundException

[英]java.io.FileNotFoundException while running code from jenkins

I am facing file not found exception while trying to run my test from jenkins, on my local its working as expected, however when m running it from jenkins it should search the file in jenkins workspace instead of my local path C:\Users\user.name\eclipse-workspace\projectFolder\src\test\java\resources\global.properties I am facing file not found exception while trying to run my test from jenkins, on my local its working as expected, however when m running it from jenkins it should search the file in jenkins workspace instead of my local path C:\Users\user .name\eclipse-workspace\projectFolder\src\test\java\resources\global.properties

can any one help me with this issue.谁能帮我解决这个问题。

Even though I don't know what your project structure looks like.即使我不知道您的项目结构是什么样的。 All Jenkins jobs have their own workspace path.所有 Jenkins 作业都有自己的工作区路径。 I guess you check out your project into the workspace by job configuration.我猜您通过作业配置将您的项目签入工作区。

To search a file from the workspace path you can just use the global WORKSPACE variable like env.WORKSPACE/my/test/resource/path/ .要从工作空间路径搜索文件,您可以使用全局WORKSPACE变量,如env.WORKSPACE/my/test/resource/path/

https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables

i have the same problem but i´m using the global variable, i have a diffFile.txt in the Workspace folder but it says it doesn´t exist File fileDiff = new File(env.WORKSPACE+'/diffFile.txt') , please, do you have any idea on how i can fix this?我有同样的问题,但我使用的是全局变量,我在 Workspace 文件夹中有一个 diffFile.txt 但它说它不存在File fileDiff = new File(env.WORKSPACE+'/diffFile.txt') ,请,你知道我该如何解决这个问题吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM