Document how to set codecov token
Opened this issue · 3 comments
Specifically CODECOV_TOKEN as a secret variable
Am I right in saying that the token should be placed around the top of azure-pipeline.yml
like this?
variables:
CODECOV_TOKEN: abc123-def456
And the token will remain secret provided the GitHub repo is private?
I think you can also add it through the Azure web interface, it's been a while tho.
The token is provided to the upload task like:
${{ if ne(variables.CODECOV_TOKEN, '') }}:
env:
CODECOV_TOKEN: $(CODECOV_TOKEN)
However, if I just add a secret pipeline variable called CODECOV_TOKEN
using the Azure web interface, ${{ if ne(variables.CODECOV_TOKEN, '') }}
doesn't seem to evaluate true, so the token is not accessible to the uploader. If I update the template to...
env:
CODECOV_TOKEN: $(CODECOV_TOKEN)
...the token is recognised by the Codecov upload script. However, we cannot just remove that line as if no CODECOV_TOKEN
variable is set, the token will literally be '$(CODECOV_TOKEN)'
and the uploader raises an error.
I don't see what the issue is with ${{ if ne(variables.CODECOV_TOKEN, '') }}
because variables.CODECOV_TOKEN
should be accessible when the template is expanded during compile time, and it should be an empty string if not set. Maybe secret variables are not accessible (like this) inside template expressions?
Do you have any examples of this template being used with a token that you could check?
(A few packages seem to be having issues with Azure Pipelines uploading to Codecov, however setting the CODECOV_TOKEN
seems to fix that even for public projects — which is why I'm keen to work out how to do this with this template.)