Using official node docker image

Run npm command with environment

pipeline:
  build:
    image: node:10
    environment:
    # https://docs.npmjs.com/misc/config#environment-variables
     - NPM_CONFIG_FOO=BAR
    commands:
     - npm build
pipeline:
  test:
    image: node:10
    commands:
     - npm test

Read more how to use this image on docker docs