如何在 docker 中使用 selenium 网格配置 jenkins?

How to configure jenkins with selenium grid in docker?

我正在尝试从本地网络中的远程服务器 运行 我的测试用例。 给定:

  1. 服务器 OS: Ubuntu 服务器 20.04
  2. Docker 已安装
  3. Jenkins 作为容器安装
  4. selenium/hub 作为容器安装
  5. selenium/node-chrome-debug 作为容器安装
  6. selenium/node-firefox-debug 作为容器安装
  7. 在 Jenkins 中创建新工作作为 Freestyle 项目,添加 GitHub 存储库和凭据,构建触发器,执行 shell (mvn -Dtest=runners.UITestRunner verify -Dbrowser="chromeRemote ")

当按下“立即构建”时,我将其作为控制台输出:

Started by user AutoSDET
Running as SYSTEM
Building in workspace /var/jenkins_home/workspace/AutoTest
The recommended git tool is: NONE
using credential 17d47c45-692c-4cec-bb04-776b05fe7894
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://github.com/autosdet/TestingProject.git # timeout=10
Fetching upstream changes from https://github.com/autosdet/TestingProject.git
 > git --version # timeout=10
 > git --version # 'git version 2.11.0'
using GIT_ASKPASS to set credentials 
 > git fetch --tags --progress -- https://github.com/autosdet/TestingProject.git +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
Checking out Revision 1168d9888205432e1b1f30bdfe65c5958855f832 (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 1168d9888205432e1b1f30bdfe65c5958855f832 # timeout=10
Commit message: "Full upload"
 > git rev-list --no-walk 1168d9888205432e1b1f30bdfe65c5958855f832 # timeout=10
[AutoTest] $ /bin/sh -xe /tmp/jenkins6787831041590861507.sh
+ mvn -Dtest=runners.UITestRunner verify -Dbrowser=chromeRemote
/tmp/jenkins6787831041590861507.sh: 2: /tmp/jenkins6787831041590861507.sh: mvn: not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE

当我在 IntelliJ 的终端中使用此命令 (mvn -Dtest=runners.UITestRunner verify -Dbrowser="chromeRemote") 时,它工作正常。但我需要 运行 来自 Jenkins 的测试用例。看起来我错过了什么,但我不知道我错过了什么。谁能帮我解决这个问题?

你需要在Jenkins中设置Maven 转到管理 Jenkins -> 全局工具配置 -> Maven