我想在 CI 测试中使用特定的运行器(它在我的电脑上运行,而不是“共享运行器”)制作我的应用程序的屏幕截图。
它是一个基本的 docker runner。
我尝试将 builds_dir
传递给具有完整路径 /home/myuser/mybuilds
的运行器配置,但在成功测试后,该文件夹为空。 (它似乎是相对于构建,而不是 linux 路径)
可能要截取屏幕截图,但路径似乎是相对的。:
app.browserWindow.capturePage().then(function (imageBuffer) {
fs.writeFile('/home/myuser/mybuilds/page-full-path.png', imageBuffer)
})
那么如何在docker中构建后访问build文件夹呢?
编辑
我可以像这样使用 artifacts
:
app.browserWindow.capturePage().then(function (imageBuffer) {
console.log("This test path");
console.log(path.join(__dirname));
var mypath = path.join(__dirname, '../..', 'testimgages', "test.png");
fs.writeFile(mypath, imageBuffer)
})
然后在 gitlab-ci.yml 中
mytest
script:
- mytests
artifacts:
paths:
-testimages
然后从 gitlab.com 下载图像,但有没有办法让它更快或在不转到 gitlab.com 的情况下在本地查看?
最佳答案
如果它在您的服务器上,那么您只需添加如下内容:
-v/some/local/path:/data/screenshots:rw
到您的 docker run 命令。它会将您服务器上的挂载本地目录绑定(bind)到容器中的/data/screenshots 。然后你保存在那里的所有内容都会出现在本地目录中。
关于docker - 如何访问特定 gitlab-runner 在 CI 测试中制作的屏幕截图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41508604/