continuous-integration - 使用 GitLab CI/CD 设置机器人框架管道

标签 continuous-integration automated-tests robotframework gitlab-ci pipeline

所以我已经编写了我的自动化机器人框架测试,它们在 GitLab 存储库中。我想每天自动运行一次。

  1. 这可能吗?
  2. 我需要一个 .gitlab-ci.yml 文件吗? (如果是,我在里面放了什么?)

最佳答案

是的,您完全可以在 gitlab ci 中运行机器人测试。

所以回答

  1. 是的,这很有可能,事实上这就是您执行管道测试的方式。您只需要构建一个 Dockerfile,其中包含在 docker 中执行框架所需的内容。这是示例 dockerfile。我建议您包装 .robot 脚本以从 bash 脚本运行(如 robot -d *.robot)。
FROM ubuntu:18.04

ENV LANG=C.UTF-8 LC_ALL=C.UTF-8

RUN apt-get update --fix-missing && \
    apt-get install -y python3-setuptools wget git bzip2 ca-certificates curl bash chromium-browser chromium-chromedriver firefox python3.8 python3-pip nano && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

RUN wget https://github.com/mozilla/geckodriver/releases/download/v0.27.0/geckodriver-v0.27.0-linux64.tar.gz
RUN tar xvf geckodriver*
RUN chmod +x geckodriver
RUN mv geckodriver /usr/bin

RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 2
RUN pip3 install --upgrade pip

RUN ln -s /usr/bin/python3 /usr/bin/python
RUN ln -s /usr/bin/pip3 /usr/bin/pip

RUN pip install rpaframework

COPY . /usr/src/

ADD robot.sh /usr/local/bin/robot.sh

RUN chmod +x /usr/local/bin/robot.sh

WORKDIR /usr/src

  1. 现在您的存储库中需要 .gitlab-ci.yml 才能拥有这样的内容。
stages:
  - build
  - run

variables:
  ARTIFACT_REPORT_PATH: "${CI_PROJECT_DIR}/reports"

build_image:
  stage: build
  variables:
    DOCKER_IMAGE_TAG: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME}
  script:
    - docker build -t ${DOCKER_IMAGE_TAG} .
  after_script:
    - docker push ${DOCKER_IMAGE_TAG}
    - docker logout

robot_tests:
  stage: run
  variables:
    DOCKER_IMAGE_TAG: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}
  image: ${DOCKER_IMAGE_TAG}
  script:
    - robot-test.sh
  artifacts:
    paths:
      - $ARTIFACT_REPORT_PATH
    when: always

应该就是这样,作业完成后,您会在存储库中的路径位置看到作业中的输出。

关于continuous-integration - 使用 GitLab CI/CD 设置机器人框架管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65090053/

相关文章:

testing - 在本地机器的网络浏览器上运行自动化测试用例 - HUDSON

java - TestNG 运行方法如上

java - 我可以将java返回的hashmap存储在机器人框架变量中吗?

python - 如何使用 Selenium 库在 Robot Framework 中编写测试用例

python - Robot Framework中的自定义执行状态

python - 在 Robot Framework 中用 Python 登录日志

c# - 如何升级 azure CI 以使用 c# 8.0

tfs - 在 TFS vnext 构建中过滤 CI 触发器到 git repo 的子文件夹

continuous-integration - GitHub Actions 运行 Espresso 测试

continuous-integration - 在 GitHub Actions 上使用 Vagrant(最好包括 VirtualBox)