I am trying to do code coverage for a flask app in Python and uploading it on the codecov.io
platform. I am trying to upload it directly via Gitlab CI, but it doesn't happen. It keeps throwing the following error:
HTTP 400
Provided token is not a UUID.
I created an account on codecov.io
and connected it to my gitlab account and selected a repository to work with. I added the token as an environment variable in gitlab CI
My CI file is:
image: ubuntu:18.04
variables:
CODECOV_TOKEN: $CODECOV_TOKEN
stages:
- coverage
- deploy
coverage:
stage: coverage
before_script:
- apt-get -y update
- apt-get -y install curl python3-pip python3.7 zip
- python3.7 -m pip install --upgrade pip
- python3.7 -V
- pip3.7 install -r requirements.txt
script:
- coverage run -m pytest
- coverage report -m
after_script:
- bash <(curl -s https://codecov.io/bash) -t $CODECOV_TOKEN
The error screenshot:
But, when I did bash <(curl -s https://codecov.io/bash) -t <token>
from the linux terminal, it was successfully uploaded.
What is the mistake that I am doing?
Your screenshot of the GitLab CI/CD variables shows that the CODECOV_TOKEN
variable is "protected": GitLab exports the variable only to pipelines running on protected branches and tags.
When running your pipeline on an unprotected branch, CODECOV_TOKEN
is not set, and the codecov script fails.
To make the variable available to pipelines running on all branches, edit the variable and uncheck "Protect variable."