NpmPublish - Examples

JFrog Pipelines Documentation

Products
JFrog Pipelines
Content Type
User Guide
ft:sourceType
Paligo

The following examples show how to configure an NpmPublish step. For more information about NpmPublish Pipeline steps, see NpmPublish.

Full Pipeline Example

NpmBuild

# This config file is templatized so that it can be easily customized. Values can be provided with a values.yml file.
template: true   # required for local templates
valuesFilePath: ./values.yml

resources:
  - name: npm_repo_jfp_example
    type: GitRepo
    configuration:
      # SCM integration where the repository is located
      gitProvider: {{ .Values.myRepo.gitProvider }}
      # Repository path, including org name/repo name
      path: {{ .Values.myRepo.path }}
      branches:
        # Specifies which branches will trigger dependent steps
        include: master

  - name: npm_buildinfo_jfp_example
    type: BuildInfo
    configuration:
      sourceArtifactory: demoArt

pipelines:
  - name: npm_pipeline_jfp_example
    steps:
      - name: npm_build_step
        type: NpmBuild
        configuration:
          affinityGroup: npm_pipeline_jfp_example
          repositoryName: npm-virtual      # required, npm repository name on artifacctory
          sourceLocation: .      # required, location of package.json file
          integrations:
            - name:  demoArt  # required
          inputResources:
            - name: npm_repo_jfp_example         # required

      - name: npm_publish_step
        type: NpmPublish
        configuration:
          affinityGroup: npm_pipeline_jfp_example
          # for payloadType npm:
          repositoryName: npm-virtual        # required, npm repository name on artifactory
          autoPublishBuildInfo: true       # optional
          integrations:
            - name: demoArt      # required
          inputSteps:
            - name: npm_build_step                # required
          outputResources:
            - name: npm_buildinfo_jfp_example                 # optional

Upload Artifactory Repo

Uploads to an Artifactory repository named npm-repo.

Note

This example is not a complete pipeline. An NpmBuild step must be part of the same pipeline.

NpmPublish

pipelines: 
  - name: npmPublishPipeline
    steps:
      - name: npmPublishStep
        type: NpmPublish
        configuration:
          deployerRepo: npm-repo
          integrations:
            - name: artifactory_integration
          inputSteps:
            - name: npmBuildStep

Upload the Result of NpmBuild Step to Artifactory Repo

Uploads the result of the NpmBuild step to an Artifactory repository named npm-repo and uploads build info. This extends example 1 in the NpmBuild documentation.

NpmPublish

pipelines: 
  - name: npmBuildPipeline
    steps:
      - name: npmBuildStep
        type: NpmBuild
        configuration:
          affinityGroup: npmBuildPipeline
          inputResources:
            - name: gitRepoResource
          integrations:
            - name: artifactory_integration
      - name: npmPublishStep
        type: NpmPublish
        configuration:
          affinityGroup: npmBuildPipeline
          deployerRepo: npm-repo
          autoPublishBuildInfo: true
          inputSteps:
            - name: npmBuildStep
          outputResources:
            - name: outputBuildInfo

Publish Build Info and Trigger Xray Scan

In this example, build info is published and an Xray scan triggered.

NpmPublish

pipelines: 
  - name: npmBuildPipeline
    steps:
      - name: npmBuildStep
        type: NpmBuild
        configuration:
          affinityGroup: npmBuildPipeline
          inputResources:
            - name: gitRepoResource
          integrations:
            - name: artifactory_integration
      - name: npmPublishStep
        type: NpmPublish
        configuration:
          affinityGroup: npmBuildPipeline
          deployerRepo: npm-repo
          autoPublishBuildInfo: true
          forceXrayScan: true
          inputSteps:
            - name: npmBuildStep
          outputResources:
            - name: outputBuildInfo