首页 > 解决方案 > 当我在 Jenkins 中运行构建时,我得到了这个错误:在 PATH 中找不到 firefox 二进制文件。确保已安装 Firefox

问题描述

我在 Jenkins 中创建了一个作业 Maven 项目,目的是编译和执行我所有的自动测试,但是当我构建作业时,我得到了这个错误:

在此处输入图像描述

对于所有场景,我都收到相同的消息错误

我应该创建一个管道来代替项目 maven 吗?

我使用链接 ssh GitLab 恢复我的项目,并且我在代理后面工作

Thnaks(y)

标签: javaseleniumjenkinsautomated-testscucumber

解决方案


这是一个docker-compose文件,它将在 chrome 上打开 7 个 FF 实例和 1 个实例。我将它与 azure 管道一起使用,但您可以将它与 jenkins 集成。您将不得不添加一个运行的詹金斯任务docker-compose

要在命令行上尝试,只需安装 docker 桌面(我将它与 mac 一起使用)并运行以下命令

docker-compose -f /path/of/file up

version: "3"
services:
  selenium-hub:
    image: selenium/hub:3.141.59-20210607
    container_name: selenium-hub
    ports:
      - "65299:4444"

  chrome:
    image: selenium/node-chrome:3.141.59-20210607
    depends_on:
      - selenium-hub
    environment:
      - HUB_HOST=selenium-hub
      - HUB_PORT=4444


  firefox:
    image: selenium/node-firefox:3.141.59-20210607
    depends_on:
      - selenium-hub
    environment:
      - HUB_HOST=selenium-hub
      - HUB_PORT=4444
    deploy:
      mode: replicated
      replicas: 7

对于docker-compose与 azure pipeline 一起使用,我正在使用以下内容。确保您已dockerRegistryEndpoint设置(在下面的示例中:Dockerhub)。我用它来运行我的黄瓜测试并将第三方黄瓜报告(PublishCucumberReport@1)集成到管道中

trigger:
- master
resources:
- repo: self
variables:
  tag: '$(Build.BuildId)'
stages:
- stage: Build
  displayName: Build and Push image
  jobs:
   - job: Build
     displayName: Build and Push
     pool:
        vmImage: 'ubuntu-latest'
     steps:
     - task: DockerCompose@0
       displayName: open browser instances
       inputs:
         containerregistrytype: 'Container Registry'
         dockerRegistryEndpoint: Dockerhub
         dockerComposeFile: '**/docker-compose.yml'
         action: 'Run a Docker Compose command'
         dockerComposeCommand: 'up -d'
         detached: true

     - task: Maven@3
       inputs:
         mavenPomFile: 'pom.xml'
         mavenOptions: '-Xmx3072m'
         jdkArchitectureOption: 'x64'
         publishJUnitResults: true
         testResultsFiles: '**/target/cucumber.html'
         goals: 'clean verify -P acceptanceTests -e -X'
         
     - task: PublishPipelineArtifact@1
       displayName: Publish cucumber report
       inputs:
         pathToPublish: $(System.DefaultWorkingDirectory)/s/target/cucumber-report/
         artifactName: 'cucumber.html'

     - task: PublishCucumberReport@1
       inputs:
         jsonDir: ./target/cucumber-report/
         outputPath: ./target/

有关文档,请参阅 - https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/docker-compose?view=azure-devops


推荐阅读