npm Integration
NPM resolves packages using the registry configured in .npmrc. To route NPM traffic through the Lineaje Proxy, configure .npmrc to use the Proxy’s NPM endpoint and authenticate with a Lineaje Personal Access Token (PAT).
Getting Started
Store the Lineaje PAT in a secure location
For example, add the token as an environmental variable:
export NPM_AUTH_TOKEN="by9...dPQ=="For CICD pipelines, like GitHub Actions, this token can be stored as a repository-level secret or an organization-level secret. A sample GitHub Action is added below for your reference.
Configure .npmrc
Create a .npmrc file in the root of the Node.js project.
registry=https://observe.fortknox.v2.prod.veedna.com/artifactory/api/npm/gos-all-proxy-npm/
//observe.fortknox.v2.prod.veedna.com/artifactory/api/npm/gos-all-proxy-npm/:_authToken=${NPM_AUTH_TOKEN}You can choose between observe mode or enforce mode. More details are here:
Modes of OperationSample Configurations
GitHub Actions
This guide explains how to configure a GitHub Actions workflow to install NPM dependencies from Lineaje GOS Artifactory and run unit tests.
1. Create the GitHub Secret
Create a repository-level or organization-level secret to store the Lineaje PAT.
Open your GitHub repository.
Go to Settings.
Open Secrets and variables.
Select Actions.
Click New repository secret.
Create the following secret:
Set the value to the Lineaje PAT.
This token will be used by
actions/setup-nodeto authenticate with the Lineaje GOS Artifactory NPM registry.
2. Add the GitHub Actions Workflow
Create the following workflow file in your repository:
Add the below content:
Jenkins
This guide explains how to configure Jenkins to build a Node.js project using FortKnox Artifactory as the NPM registry.
1. Configure Node.js in Jenkins
Go to Manage Jenkins.
Open Tools or Global Tool Configuration.
Find the NodeJS installations section.
Click Add NodeJS.
Set the name as:
Select the required Node.js version.
Save the configuration.
The name must match the Jenkinsfile value:
2. Add Artifactory Credentials in Jenkins
Go to Manage Jenkins.
Open Credentials.
Select the appropriate credentials scope, usually:
Click Add Credentials.
Select credential type:
Enter your SBOM360 email as username and the Lineaje PAT as password.
Set the credential ID, for example:
Save the credential.
This credential ID will be used in the Jenkinsfile:
3. Add .npmrc to the Project
Create a .npmrc file in the root of the Node.js project.
Example:
4. Add the Jenkinsfile
Add the following Jenkinsfile to the root of the repository.
Verifying Proxy Routing
The --verbose flag causes npm to log the full tarball URL. Confirm the Proxy URL appears:
To detect policy violations, search build logs for the string. To learn more, see Detecting Policy Violations in Build Logs.
Last updated