Test results upload from GitLab
GitLab upload workflow uses allurectl. to upload the test results.
Authenticate GitLab build jobs
Authentication token
For a user on Allure TestOps side you need to create API token.
This API token will be used by GitLab to authenticate on Allure TestOps server.
Log in to Allure TestOps with account you are going to use to upload test results.
Click on your avatar and go to Your profile.
In the section API tokens click a green button that says Create.
Name your API token and click Submit. Always give meaningful names to all the configuration parameters.
Allure will randomly generate the token and show you in modal window.
Copy the token and save it in a safe place as it cannot be retrieved by Allure TestOps means.
Configure GitLab project to upload the test results
Add your Allure server instance information to GitLab' configuration
Navigate to CI / CD project settings
Navigate to Variables section
Create 3 variables as shown below
ALLURE_ENDPOINT
- Allure TestOps URL (for example:http://testops.company.com
).ALLURE_TOKEN
- Allure TestOps token created in the previous steps.ALLURE_PROJECT_ID
- Allure TestOps project ID to which you are going to upload the results results.
Build jobs
Single job pipeline
stages:
- test
variables:
ALLURE_LAUNCH_NAME: "${CI_PROJECT_NAME} - ${CI_COMMIT_SHORT_SHA}"
ALLURE_LAUNCH_TAGS: "${CI_COMMIT_REF_NAME}, gitlab, demo, pytest, skip-live-doc, ignore"
ALLURE_RESULTS: "./allure-results"
TESTS_ENDPOINT: "https://pytest.never.never.never.give.up"
TESTS_BROWSER: "firefox"
TESTS_BRANCH: ${CI_COMMIT_REF_NAME}
test:
image: python:3.9.1
stage: test
before_script:
- wget https://github.com/allure-framework/allurectl/releases/latest/download/allurectl_linux_386 -O ./allurectl
- chmod +x ./allurectl
- pip install pytest allure-pytest
script:
- echo ${ALLURE_USER_USED}
- ./allurectl --version
- ./allurectl watch -- pytest --alluredir=${ALLURE_RESULTS} || true
Second condition for the selective rerun is the support of this feature in the Allure FrameWork adaptor for your test framework.
Multi-job pipeline
stages:
- unit
- func
variables:
ALLURE_LAUNCH_NAME: "${CI_PROJECT_NAME} - ${CI_COMMIT_SHORT_SHA}"
ALLURE_LAUNCH_TAGS: "${CI_COMMIT_REF_NAME}, gitlab, multijob, fake-results"
ALLURE_RESULTS: "allure-results"
TESTS_ENDPOINT: "https://never.never.never.let.you.down"
TESTS_BROWSER: "firefox"
TESTS_BRANCH: ${CI_COMMIT_REF_NAME}
unit-tests:
image: python:3.9.1
stage: unit
before_script:
- wget https://github.com/allure-framework/allurectl/releases/latest/download/allurectl_linux_386 -O ./allurectl
- chmod +x ./allurectl
- chmod +x ./tests1.sh
- ls -l $ALLURE_RESULTS || true
script:
- ./allurectl watch -- ./tests1.sh
func-test:
image: python:3.9.1
stage: func
before_script:
- wget https://github.com/allure-framework/allurectl/releases/latest/download/allurectl_linux_386 -O ./allurectl
- chmod +x ./allurectl
- chmod +x ./tests2.sh
script:
- ./allurectl watch -- ./tests2.sh