Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setup Robot Framework pipeline with GitLab CI / CD

So i have written my automated Robot Framework tests and they are in a GitLab repo. I want to run these automatically once a day.

  1. Is this possible?
  2. Do I need a .gitlab-ci.yml file for it? (if yes what do I put in it?)
like image 658
majinster Avatar asked Oct 25 '25 14:10

majinster


1 Answers

Yes you can totally run the robot tests in gitlab ci.

so answer

  1. Yes its very much possible , infact that is how you execute pipeline tests . You just need to build a Dockerfile that has the things you need to execute the framework inside docker. Here's the sample dockerfile. I would suggest you wrap the .robot script to run from bash script (like 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. Now you need .gitlab-ci.yml in your repository to have a content like this.
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

That should be it and once the job finishes you would see the output in the job at the path location in the repository.

like image 116
vgdub Avatar answered Oct 28 '25 04:10

vgdub