Merge "upload-npm : support authToken argument"

This commit is contained in:
Zuul 2022-09-08 01:13:45 +00:00 committed by Gerrit Code Review
commit 3c6ec6ec27
3 changed files with 18 additions and 1 deletions

View File

@ -17,6 +17,13 @@ Upload javascript packages to npm
Password to use to log in to npm.
.. zuul:rolevar:: authToken
An auth token (issued from the npm server) to authenticate with.
This is required if you are using two-factor authentication. If
specifying an authToken you should not specify ```username`` and
``password``.
.. zuul:rolevar:: email
Email associated with the npm account.

View File

@ -1,3 +1,10 @@
- name: Validate password/token combo
fail:
msg: 'Specify either username/password or authToken'
when: >
(npm_credentials.authToken is defined) and
((npm_credentials.username is defined) or (npm_credentials.password is defined))
# This is not optimized, but allows for getting a version of node in the
# home dir.
- name: Create .npmrc configuration file

View File

@ -4,7 +4,10 @@ init.author.url={{ npm_credentials.author_url }}
tag-version-prefix=
sign-git-tag=true
{% if npm_credentials.username is defined %}
//registry.npmjs.org/:username={{ npm_credentials.username }}
//registry.npmjs.org/:_password={{ npm_credentials.password }}
{% else %}
//registry.npmjs.org/:_authToken={{ npm_credentials.authToken }}
{% endif %}
//registry.npmjs.org/:email={{ npm_credentials.author_email }}