CONTROLLED DATA
Leidos Proprietary - US Citizens ONLY
The information contained herein is proprietary to Leidos, Inc. It may not be used, reproduced, disclosed, or exported without the written approval of Leidos.

SDO projects using NPM to manage Javascript packages, such as for NodeJS,  first need to authenticate with Artifactory using basic authentication. This article outlines the steps required to perform this procedure from either the command line or from within a CI/CD pipeline.

Step-by-step guide

References

Prerequisites

  • A project NPM repository exists in Artifactory.
  • NPM is installed locally or is available from within the CI/CD pipeline in Bamboo or Jenkins.

Visit the SDO Help Desk at https://helpdesk.sdo.leidos.com/servicedesk/customer/portal/4 for questions or to request resources.

Command line

The configuration for NPM can exist in a number of locations. See NPMRC for details. The per-user config file (~/.npmrc) will be used in this example.

  1. Set the registry in ~/.npmrc.

    # npm config set registry https://artifactory.sdo.leidos.com/artifactory/api/npm/<NPM-REPO>/

  2. Retrieve the Basic Auth credentials from Artifactory and write them to ~/.npmrc.

    # curl --user <USERNAME>:<PASSWORD> https://artifactory.sdo.leidos.com/artifactory/api/npm/auth >> ~/.npmrc

  3. Verify

    # cat ~/.npmrc

  4. Navigate to the NodeJS directory containing the package.json file and install dependencies.

    # npm install

  5. Verify that all dependencies resolve as expected.

CI/CD

This example uses a Bamboo 'script' task to illustrate how the same steps can be performed in a Bamboo build plan. 

  1. In the Variables tab of the Plan Configuration, add variables for the Artifactory NPM repository, username and password. For example:


  2. In the Task configuration under the Stages tab, click Add task.

  3. Select the Script task.

  4. In the script pane, add the same steps as outlined above in the Command Line section making sure to substitute the variables from Step 1 for the actual values. For example:



  5. Run the plan and verify that the authentication steps works as expected.