如何将测试报告部署回Github或我的本地?我使用webhook建立了从Github到Jenkins的连接,使用Jenkins设置/Pipeline建立了从Jenkins到Github的连接,并添加了我的仓库。测试的结果显示在Jenkins/控制台输出中。如何将结果存储在其他地方(如GithUb)或我的本地或某个服务器上,是否有此设置?
daupos2t1#
有很多方法可以做到这一点,但这里有一个方法。
pipeline { agent any stages { stage('Sample') { steps { script { echo "Somehitng 1" echo "Something 2" // Read the console log def consoleLog = Jenkins.getInstance().getItemByFullName(env.JOB_NAME).getBuildByNumber(Integer.parseInt(env.BUILD_NUMBER)).logFile.text //Write the log to a file writeFile(file: "Log_${BUILD_NUMBER}.txt", text: consoleLog, encoding: "UTF-8") sh''' git add * git commit -m "Add console log" git push ''' } } } } }
1条答案
按热度按时间daupos2t1#
有很多方法可以做到这一点,但这里有一个方法。