我正在尝试在Jenkins Blue Ocean上运行基本的Selenium GUI测试,该测试已从Docker容器本地运行。我的过程是:
我已经尝试过多次设置安装Firefox和Geckodriver的迭代,但始终会收到错误消息
HOOK-ERROR in before_tag(tag=WebDriver): WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
我正在将geckodriver提取到/ usr / bin并使其可执行。但是,如果我登录到正在执行构建的容器,它似乎无法被识别。即使我与geckodriver在同一目录中,运行geckodriver -v
也会产生错误bash: /usr/bin/geckodriver: No such file or directory
。任何想法出什么事了吗?
这是我的Dockerfile
FROM alpine:latest
RUN apk add python3
RUN apk add firefox-esr
# Install Gecko Driver
ENV GECKODRIVER_VERSION 0.26.0
ENV BIT 64
ENV DOWNLOAD_URL https://github.com/mozilla/geckodriver/releases/download/v${GECKODRIVER_VERSION}/geckodriver-v${GECKODRIVER_VERSION}-linux${BIT}.tar.gz
RUN wget ${DOWNLOAD_URL}
RUN tar -xzvf geckodriver-v${GECKODRIVER_VERSION}-linux${BIT}.tar.gz
RUN chmod 755 geckodriver
RUN cp geckodriver /usr/bin/.
RUN rm geckodriver*
这是我的Jenkinsfile
pipeline {
agent {
dockerfile true
}
stages {
stage("Prepare") {
steps {
sh """
export PATH=$PATH:/usr/bin
pip3 install -r requirements.txt
"""
}
}
stage("Test") {
steps {
sh """
export PATH=$PATH:/usr/bin
python3 execute.py
"""
}
}
}
post {
always {
junit "junit/*.xml"
}
}
}