Issue in npm install from Concourse pipeline

Hi,

I am using Concourse to clone, build and deploy an angular app to cf. The package.json file contains some dependencies from private github url of my organization. The npm install command in my build script is failing due to what seems to be SSH authentication issue to my private github repo. Can someone please help me with this as i am stuck and unable to move forward with this.

My pipeline config as follows (pipeline.yml):

groups:
- name: PR-Generate (Deploy to DEV)
  jobs:
    - myportal-dev

resources:
- name: deploy-dev
  type: cf
  check_every: 168h
  source:
    api: https://my.org.api
    organization: MY_ORG
    space: MY_SPACE
    username: ((myuser))
    password: ((mypass))
    
- name: myportal-pr-gen
  type: pull-request
  source:
    api_endpoint: https://github.myorg.com/mypath
    repo: myrepo/myrepopath
    access_token: ((github-access-token.Key))
    uri: git@github.myorg.com:myrepo/myrepopath.git
    only_mergeable: true
    base: develop
    require_review_approval: false
    paths:
      - web/myportal/*
    private_key: |
     ((github-key.key))

resource_types:
- name: pull-request
  type: docker-image
  source:
    repository: jtarchie/pr

jobs:
- name: myportal-dev
  public: true
  plan:
  - get: repo
    trigger: true
    resource: myportal-pr-gen
    version: every
  - task: build
    privileged: true
    params:
      CONFIG_ENV: int
    file: repo/tasks/build.yml
  - put: deploy-dev
    params:
      manifest: repo/web/myportal/manifest.yml
      path: build-output/dist

Build.yml:

platform: linux

image_resource:
  type: docker-image
  source:
    repository: node
inputs: 
  - name: repo
outputs:
  - name: build-output
run:
  path: sh
  args:
  - -exc
  - |
    set -e -u -x
    node --version
    npm --version
    npm install -g n   # Install n globally
    n 8.11.3          # Install and use v10.15.3
    node --version

    echo "Install Angular-CLI"
    npm install -g @angular/cli@6.0.8

    echo "Moving to myportal"
    cd repo/web/myportal 

    echo "Installing Packages"
    npm install -verbose

    echo "Build Angular Code"
    ng build --env=$CONFIG_ENV
                
    echo "Copying My Portal in output folder(exist on root)"
    cp -R ./dist ../../../build-output

Error that i am seeing in Concourse web console:

Successfully pulled node@sha256:12345a50ed624874dbbb17552ec4adb6f396f9abcd8d4.

  • set -e -u -x

  • node --version
    v12.7.0

  • npm --version
    6.10.0

  • npm install -g n
    25h/usr/local/bin/n -> /usr/local/lib/node_modules/n/bin/n

  • n@5.0.1
    added 1 package from 4 contributors in 0.362s

  • n 8.11.3

    installing : node-v8.11.3
    mkdir : /usr/local/n/versions/node/8.11.3
    fetch : https://nodejs.org/dist/v8.11.3/node-v8.11.3-linux-x64.tar.gz
    installed : v8.11.3

  • node --version
    v8.11.3

  • echo Install Angular-CLI
    Install Angular-CLI

  • npm install -g @angular/cli@6.0.8
    25h/usr/local/bin/ng -> /usr/local/lib/node_modules/@angular/cli/bin/ng
    25h

@angular/cli@6.0.8 postinstall /usr/local/lib/node_modules/@angular/cli
node ./bin/ng-update-message.js

25hnpm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/@angular/cli/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})

  • @angular/cli@6.0.8
    added 240 packages in 9.385s
  • echo Moving to myportal
    Moving to myportal
  • cd repo/web/myportal
  • echo Installing Packages
    Installing Packages
  • npm install -verbose
    npm info it worked if it ends with ok
    npm verb cli [ ‘/usr/local/bin/node’,
    npm verb cli ‘/usr/local/bin/npm’,
    npm verb cli ‘install’,
    npm verb cli ‘-verbose’ ]
    npm info using npm@5.6.0
    npm info using node@v8.11.3
    npm verb npm-session 3efcb8198b681dfd
    25hnpm info lifecycle myportal@1.1.0~preinstall: myportal@1.1.0
    The authenticity of host ‘github.myorg.com (12.345.67.88)’ can’t be established.ealTree
    ECDSA key fingerprint is SHA256:T95soGQxObRlTvmai/ld4nbNMM74BB1V4qenJzPL6d8.
    [ …] \ loadIdealTree:loadAllDepsIntoIdealTree: sill

My package.json contains dependencies on private modules as follows:

{
  "name": "myportal",
  "version": "1.1.0",
  "license": "UNLICENSED",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "build-dev": "ng build -dev",
    "build-int": "ng build --env=int && gulp compress && gulp ad-int",
    "build-qa": "ng build --env=qa && gulp compress && gulp ad-int",
    "build-staging": "ng build --env=staging && gulp compress && gulp ad-int",
    "build-prod": "ng build -prod && gulp compress && gulp ad-prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": false,
  "publishConfig": {
    "registry": "https://artifactory.myorg.net/artifactory/api/npm/myapp-libs-snapshot/"
  },
  "dependencies": {
    "@agm/core": "1.0.0-beta.5",
    "@angular-redux/store": "6.5.7",
    "@angular/animations": "7.2.7",
    "@angular/cdk": "7.3.2",
    **"mypackage.js": "git+ssh://git@github.myorg.com:mypath/mypackage.git",**

    "core-js": "2.4.1",
    "file-saver": "1.3.3",
    "font-awesome": "4.7.0",
    "hammerjs": "2.0.8",
    "intl": "1.2.5",
    "jquery": "3.2.1",
    "jquery-mapael": "git+https://git@github.com:443/neveldo/jQuery-Mapael#2.1.0",
    "ng2-charts": "^1.6.0",
    "ng2-google-charts": "^2.0.0",
    "ng2-search-filter": "^0.4.7",
    "os": "^0.1.1",
    "pace": "git+https://git@github.com:443/HubSpot/pace#v0.7.7",
  }
}

Thanks & Regards,
Mike

first hit on google: https://stackoverflow.com/questions/18710120/the-authenticity-of-host-github-com-192-30-252-128-cant-be-established

I would suggest doing some more googling. It sounds like an NPM / git auth issue, not something specific to Concourse (sorry, I know that’s not the most helpful answer).

Hi @eedwards-sk yes i already went through that SO link and also google quite a bit. But not able to find any working solution. Here’s what i tried:

in build.yml added the following:

echo "SSH --"
ssh -o StrictHostKeyChecking=no git@12.345.67.88 "exit"

It gives error message as :
Permission denied (publickey).

So i tried to view the public key of the concourse server by adding the following:

cd ~/.ssh
ls

But it gives error message as:

can’t cd to root/.ssh

Is there a way to view the public key of Concourse server or to add it to Github ?
Is there a concourse resource for doing npm install instead of using the shell script ?
Is this a known issue in Concourse when doing npm install on project that contains private dependencies? If yes then is there a work around or solution to do the ssh handshake between Concourse and github server ?

Thanks & Regards,
Mike

:thinking: You may need to start up an ssh-agent process and explicitly add the key to your keychain with ssh-add path/to/key.

Try adding this to your task script (assuming you’re passing a key somehow to the task):

eval $(ssh-agent)
trap "kill $SSH_AGENT_PID" EXIT

ssh-add path/to/key
1 Like