jenkins - 如何从运行在 VM 上的 Jenkins 在主机上打开新的浏览器页面
问题描述
好吧,标题描述了这个问题,Jenkins 安装并运行在 Ubuntu VM 上,Windows 作为主机。我正在通过 Windows 访问 Jenkins UI,并想添加一个功能,在某些阶段 Jenkins 将在 Windows 主机中打开给定 URL 的网页,最好使用 Chrome。
更新:根据@vinWin 的建议,我正在尝试在 Windows 节点上运行 python + Selenium + Chormedriver 脚本,python 脚本是来自“Chromedriver”的示例代码,当我在 Pycharm、PowerShell 和通过批处理文件,这意味着我可以看到chrome浏览器的打开和google的搜索。
当我尝试在管道构建中通过 Jenkins slave 运行它时,似乎脚本运行没有错误,但我没有看到浏览器打开......
詹金斯管道:
pipeline {
agent {label 'WindowsHost'}
stages {
stage('Burn Image'){
steps{
bat 'wmic computersystem get name'
bat 'echo %PATH%'
echo env.PATH
echo bat(returnStdout: true, script: 'set')
bat 'python C:\\git\\tester\\dart_framework\\measurments\\webs.py'
}
}
}
}
在日志中有一些行似乎指出了一些运行问题......可能是权限或兼容性......
*如何在此处附加日志文件?
来自 Windows 代理的 Chormedriver 日志:
[1582176618.238][INFO]: Cannot switch to US keyboard layout - some keys may
be interpreted incorrectly
[1582176618.238][INFO]: Launching chrome: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-automation --enable-blink-features=ShadowDOMV0 --enable-logging --load-extension="C:\WINDOWS\TEMP\scoped_dir9180_1355856553\internal" --log-level=0 --no-first-run --password-store=basic --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir="C:\WINDOWS\TEMP\scoped_dir9180_1999495287" data:,
[1582176618.439][DEBUG]: DevTools HTTP Request: http://localhost:56085/json/version
[1582176618.742][DEBUG]: DevTools HTTP Response: {
"Browser": "Chrome/80.0.3987.116",
"Protocol-Version": "1.3",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.116 Safari/537.36",
"V8-Version": "8.0.426.23",
"WebKit-Version": "537.36 (@dc00a510e4c2ae25c4d084cc3d946fc782249224)",
"webSocketDebuggerUrl": "ws://localhost:56085/devtools/browser/b1d2c87f-9e59-4493-835b-a937fe029787"
在 Windows 环境下运行时的 Chromedriver 日志:
[1582180734.741][INFO]: Launching chrome: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-automation --enable-blink-features=ShadowDOMV0 --enable-logging --load-extension="C:\Users\udiw\AppData\Local\Temp\scoped_dir10612_170753985\internal" --log-level=0 --no-first-run --password-store=basic --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir="C:\Users\udiw\AppData\Local\Temp\scoped_dir10612_1995928923" data:,
[1582180734.963][DEBUG]: DevTools HTTP Request: http://localhost:56688/json/version
[1582180735.267][DEBUG]: DevTools HTTP Response: {
"Browser": "Chrome/80.0.3987.116",
"Protocol-Version": "1.3",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.116 Safari/537.36",
"V8-Version": "8.0.426.23",
"WebKit-Version": "537.36 (@dc00a510e4c2ae25c4d084cc3d946fc782249224)",
"webSocketDebuggerUrl": "ws://localhost:56688/devtools/browser/ebb7f495-4c7e-48a3-9900-f7fdea8a8ac8"
解决方案
推荐阅读
- angular - 使用 Apache Webserver 代理 Angular 和 Apache Sling 服务器
- django - 从 Fullname 字段生成用户名并添加 8 个字符字符串
- firebase - 访问 API 并从预定函数写入 Cloud Firebase
- excel - Excel公式返回第一个静态字符和两个可能的第二个字符之一之间的字符串?
- java - 选择银行账户并使用菜单使用该账户
- javascript - 为什么这个简单的 hello world Vue 应用程序会因未找到挂载而失败?
- amazon-web-services - 在 appspec.yml 中提到可执行文件的位置
- c++ - 在 Visual Studio Code Linux 上激活 conda 环境
- android - Fire base google 身份验证不会传递真实的虚构信息
- java - 尝试使用正则表达式查找最后一个大写字符的索引