Files
plugin-drone-npm/DOCS.md
T
2017-02-10 17:00:08 -08:00

2.6 KiB

Use this plugin for publishing libraries to public or private NPM registries.

Config

The following parameters are used to configure the plugin:

  • username - the username for the account to publish with
  • password - the password for the account to publish with
  • token - the deploy token to publish with
  • email - the email address associated with the account to publish with.
  • registry - the registry URL to use (https://registry.npmjs.org by default)
  • folder - the folder, relative to the workspace, containing the library (uses the workspace directory, by default)
  • tag - the tag to use when publishing the package (does not set one by default)
  • *access - the access level to use for scoped packages (does not set one by default)

The following secret values can be set to configure the plugin.

  • NPM_USERNAME - corresponds to username
  • NPM_PASSWORD - corresponds to password
  • NPM_TOKEN - corresponds to token
  • NPM_EMAIL - corresponds to email
  • NPM_REGISTRY - corresponds to registry

It is highly recommended to put the NPM_PASSWORD or NPM_TOKEN into secrets so it is not exposed to users. This can be done using the drone-cli.

drone secret add --image=plugins/npm \
    octocat/hello-world NPM_PASSWORD pa55word

drone secret add --image=plugins/npm \
    octocat/hello-world NPM_TOKEN pa55word

Then sign the YAML file after all secrets are added.

drone sign octocat/hello-world

See secrets for additional information on secrets

Authentication method

NPM registries typically authenticate based on a username password pair. However NPM Enterprise users can also authenticate through tokens.

If a token value is encountered the plugin will use that. If it is not present then the plugin will default to username/password.

Example

Global NPM with NPM_PASSWORD as a secret:

pipeline:
  npm:
    image: plugins/npm
    username: bob
    email: bob@bob.me

A private NPM registry, such as Sinopia with NPM_PASSWORD as a secret:

pipeline:
  npm:
    image: plugins/npm
    username: drone
    email: drone@drone.io
    registry: "http://myregistry:4873"

NPM Enterprise registry with NPM_TOKEN as a secret:

pipeline:
  npm:
    image: plugins/npm
    registry: "http://myregistry:8081"