如何访问在特定 gitlab-runner 上的 CI 测试中制作的屏幕截图
How to access screen shots made in CI test on specific gitlab-runner
我想使用特定的运行程序在 CI 测试中制作我的应用程序的屏幕截图(它在我的电脑上运行,而不是 "shared-runner")。
它是一个基本的 docker 跑步者。
我尝试将 builds_dir
传递给具有完整路径 /home/myuser/mybuilds
的运行器配置,但在成功测试后,该文件夹为空。 (它似乎与构建相关,而不是 linux 路径)
可能要截屏,但路径似乎是相对的。:
app.browserWindow.capturePage().then(function (imageBuffer) {
fs.writeFile('/home/myuser/mybuilds/page-full-path.png', imageBuffer)
})
那么如何在 docker 构建后访问构建文件夹?
编辑
我可以这样使用 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 运行 命令。它会将您服务器上的挂载本地目录绑定到容器中的 /data/screenshots 。然后你保存在那里的所有内容都会出现在本地目录中。
如果您不想添加卷,您可以使用 docker cp
:
复制文件
docker cp <containerId>:/data/screenshots /local/path
您可以使用 docker ps
找到您的容器 ID。
我想使用特定的运行程序在 CI 测试中制作我的应用程序的屏幕截图(它在我的电脑上运行,而不是 "shared-runner")。
它是一个基本的 docker 跑步者。
我尝试将 builds_dir
传递给具有完整路径 /home/myuser/mybuilds
的运行器配置,但在成功测试后,该文件夹为空。 (它似乎与构建相关,而不是 linux 路径)
可能要截屏,但路径似乎是相对的。:
app.browserWindow.capturePage().then(function (imageBuffer) {
fs.writeFile('/home/myuser/mybuilds/page-full-path.png', imageBuffer)
})
那么如何在 docker 构建后访问构建文件夹?
编辑
我可以这样使用 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 运行 命令。它会将您服务器上的挂载本地目录绑定到容器中的 /data/screenshots 。然后你保存在那里的所有内容都会出现在本地目录中。
如果您不想添加卷,您可以使用 docker cp
:
docker cp <containerId>:/data/screenshots /local/path
您可以使用 docker ps
找到您的容器 ID。