Jenkins管道和java.nio.file。*方法的問題
這是管道腳本的規(guī)范。它寫在@L_419_0@。
readFile步驟從工作空間中加載文本文件并返回其內容 (請勿嘗試使用java.io.File方法-這些將引用Jenkins運行所在的主文件上的文件,而不是當前工作空間中的文件)。
還有一個writeFile步驟可以將內容保存到工作空間中的文本文件中
fileExists 步驟檢查文件是否存在而不加載它。
您可以在節(jié)點中使用這些Jenkins步驟來代替java.io.File或java.nio.file.Files如下所述。
String slavePath = ’C:Somethingonlyonslavenode’String masterPath = ’D:Somethingonlyonmasternode’stage(’One’) { node (’slave’) {bat returnStatus: true, script: ’set’println fileExists(slavePath) // Should be trueprintln fileExists(masterPath) // Should be false } node (’master’) {bat returnStatus: true, script: ’set’println fileExists(slavePath) // falseprintln fileExists(masterPath) // true }}解決方法
我正在嘗試使用java.nio.file。*中的方法在Jenkins管道中執(zhí)行一些基本文件操作。無論代碼所在的節(jié)點塊如何,代碼都在主節(jié)點上執(zhí)行。在管道中,我已經(jīng)驗證了各種節(jié)點塊是正確的-它們唯一地標識特定的節(jié)點。但是,pathExists(以及其他移動,復制或刪除文件的代碼)始終在主節(jié)點上執(zhí)行。任何想法正在發(fā)生或如何解決?
import java.nio.file.*String slavePath = ’C:Somethingonlyonslavenode’String masterPath = ’D:Somethingonlyonmasternode’def pathExists (String pathName){ def myPath = new File(pathName) return (myPath.exists()) }stage(’One’) { node (’slave’) {bat returnStatus: true,script: ’set’println (pathExists(slavePath)) // Should be true but is false.println (pathExists(masterPath)) // Should be false but is true. } node (’master’) {bat returnStatus: true,script: ’set’println (pathExists(slavePath)) // falseprintln (pathExists(masterPath)) // true }}
相關文章:
1. node.js - nodejs,express搭建,為什么ejs模板被解析成pre了?2. javascript - postcss-loader在webpack2的使用.3. angular.js - js 點擊事件onclick=“”,引號內的函數(shù)名字 可以為 變量嗎4. css3 實現(xiàn)一個線性漸變出現(xiàn)的問題?5. angular.js - Angular中關于控制器編寫方式的問題6. android - 如何使用view group的bitmap做一個倒影效果,同時忽略scale的view7. linux - 無法使用ifconfig來配置ip信息8. mysql - 關聯(lián)數(shù)據(jù)表的更新問題9. 求救一下,用新版的phpstudy,數(shù)據(jù)庫過段時間會消失是什么情況?10. mysql - mybatis 查詢 統(tǒng)計某個列數(shù)量 ,根據(jù)一個列,分組查詢,在xml文件如何接收
