Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how to set codecov token #17

Open
astrofrog opened this issue Oct 31, 2019 · 3 comments
Open

Document how to set codecov token #17

astrofrog opened this issue Oct 31, 2019 · 3 comments

Comments

@astrofrog
Copy link
Contributor

Specifically CODECOV_TOKEN as a secret variable

@ConorMacBride
Copy link
Member

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?

@Cadair
Copy link
Member

Cadair commented Oct 5, 2021

I think you can also add it through the Azure web interface, it's been a while tho.

@ConorMacBride
Copy link
Member

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants