.NPRC file environment variable from Appveyor UI
Hi,
I am using a .nprc file for the Luna component. I am setting GitHub token values as an environment variable and setting these values in the appveyor.yml file and accessing these values from UI. But it throws below error please help me out.
ERR! 401 Unauthorized - GET https://npm.pkg.github.com/download - unauthenticated: User cannot be authenticated with the token
.NPRC file content
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
Appveyor.yml file
before_build:
- cmd: |
NuGet restore DeliveryHubDeploy.sln
set GITHUB_TOKEN = %Luna_GitHub_Token%
%Luna_GitHub_Token% This value I stored in Appveyor UI in the environment variable
-
Luna.PNG 12.8 KB
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Feodor Fitsner on 14 Jun, 2023 01:56 PM
Try updating
.npmrc
contents with an actual token:Also, when setting variable on AppVeyor UI make sure: a) "lock" icon is on to mark variable as secure, b) variable value is pasted as plain text, without prior encrypting with "Encrypt YAML" tool, c) you are not testing that in PR as by default secure variables are not set in PR builds. Hope that helps.
2 Posted by vijay.malhi on 15 Jun, 2023 04:06 PM
Hi Fedor,
Thank you for your response to the above. I tried what you said still getting the same issue. Maybe I am missing anything. I have added the actual token key name in the NPRC file which is attached you can see.
Do I need to change anything in the AppVeyor.yml file?
Please help me with this.
Support Staff 3 Posted by Feodor Fitsner on 19 Jun, 2023 01:49 PM
It's not the same.
%Luna_GitHub_Token%
won't be automatically replaced inside.npmrc
for you.What I meant is writing a real token value to to
.npmrc
file, not an env variable name.When you do this
%Luna_GitHub_Token%
is replaced with variable value byecho
command and overwrites the contents of.npmrc
:Feodor Fitsner closed this discussion on 19 Aug, 2023 09:03 PM.