0
votes

Description

I am trying to set up JFrog’s Artifactory Pro (v 6.0.1) to store and cache dependencies of my projects. I want to use JFrog CLI to collect and publish the npm-build information to Artifactory just like it is described in this (https://jfrog.com/blog/npm-flies-with-jfrog-cli/) blog-post, but I want to be able to do it as a non-admin user.

Setup

Artifactory contains a virtual repository called npm, that is a collection of a local (named npm-local) and a remote (named npm-remote) repository.

There are two users: the user called admin that has admin access and a user called developer that does not have admin access.

Config for JFrog CLI:

# create a configuration for the admin
jfrog rt config --user=admin \
    --password=admin \
    --url=http://localhost:8081/artifactory \
    --interactive=false rt_admin

# create a configuration for the developer
jfrog rt config --user=developer \
    --password=developer \
    --url=http://localhost:8081/artifactory \
    --interactive=false rt_dev

What I am doing

For this test I am trying to build the simple-node-js-react-npm-app (https://github.com/jenkins-docs/simple-node-js-react-npm-app) and publish it to the local npm repository in Artifactory using the following JFrog CLI commands:

jfrog rt npm-install npm \
    --build-name=simple \
    --build-number=1.0.0 \
    --server-id=rt_dev

this produces the following the following error just before the command is done (if errors during npm-install phase are ignored):

[Info] Collecting dependencies information, this might take several minuets...
[Error] Artifactory response: 400 Bad Request
For permissions reasons AQL demands the following fields: repo, path and name.

When i go on with

jfrog rt npm-publish npm \
    --build-name=simple \
    --build-number=1.0.0 \
    --server-id=rt_dev
jfrog rt build-publish simple 1.0.0 --server-id=rt_dev

the freshly published artifact has zero dependencies.

If publish the same way as an admin

jfrog rt npm-install npm \
    --build-name=simple \
    --build-number=1.0.1  \
    --server-id=rt_admin
jfrog rt npm-publish npm \
    --build-name=simple \
    --build-number=1.0.1 \
    --server-id=rt_admin
jfrog rt build-publish simple 1.0.1 --server-id=rt_admin

i get over 1000 dependencies.

How can i get the same result as a non admin user?

1

1 Answers

0
votes

If this helps, I have tried to reproduce this behavior but was not able to. Have successfully built and publish with a non-admin user using the CLI (see build log below).

In your case, you can debug the JFrog CLI by running it on DEBUG.

$ echo "$ARTIFACTORY_URL"
https://arielk.jfrog.io/arielk
$ echo "$ARTIFACTORY_USER"
npm
$ echo "$ARTIFACTORY_NPM_REPOSITORY"
npm
$ chmod 777 jfrog
$ ./jfrog rt config --url=$ARTIFACTORY_URL --user=$ARTIFACTORY_USER --password=$ARTIFACTORY_PASS
Artifactory server ID: [Info] Encrypting password...
$ ./jfrog rt c show
Server ID: Default-Server
Url: https://arielk.jfrog.io/arielk/
User: npm
Password: ***
Default:  true

$ ./jfrog rt npmi $ARTIFACTORY_NPM_REPOSITORY --build-name=gitlabci-npm-artifactory --build-number=$CI_JOB_ID
[Info] Running npm Install.
npm notice created a lockfile as package-lock.json. You should commit this file.
{
  "added": [
    {
      "action": "add",
      "name": "inherits",
      "version": "2.0.1",
      "path": "/builds/ArielKJFrog/NPM-TEST/node_modules/inherits"
    },
    {
      "action": "add",
      "name": "util",
      "version": "0.10.3",
      "path": "/builds/ArielKJFrog/NPM-TEST/node_modules/util"
    },
    {
      "action": "add",
      "name": "assert",
      "version": "1.4.1",
      "path": "/builds/ArielKJFrog/NPM-TEST/node_modules/assert"
    },
    {
      "action": "add",
      "name": "colors",
      "version": "1.3.0",
      "path": "/builds/ArielKJFrog/NPM-TEST/node_modules/colors"
    }
  ],
  "removed": [],
  "updated": [],
  "moved": [],
  "failed": [],
  "warnings": [],
  "elapsed": 3734
}
[Info] Collecting dependencies information, this might take several minuets...
[Info] npm install finished successfully.
$ ./jfrog rt bce gitlabci-npm-artifactory $CI_JOB_ID
[Info] Collecting environment variables...
[Info] Collected environment variables for gitlabci-npm-artifactory/72931109.
$ ./jfrog rt npmp $ARTIFACTORY_NPM_REPOSITORY --build-name=gitlabci-npm-artifactory --build-number=$CI_JOB_ID
[Info] Running npm Publish
npm notice 
npm notice package: [email protected]
npm notice === Tarball Contents === 
npm notice 693B    package.json        
npm notice 1.3kB   .gitlab-ci.yml      
npm notice 129B    index.js            
npm notice 20.2MB  jfrog               
npm notice 947B    README.md           
npm notice 497.7kB img/Screen_Shot1.png
npm notice 379.3kB img/Screen_Shot2.png
npm notice 420.0kB img/Screen_Shot3.png
npm notice 490B    test/test.js        
npm notice === Tarball Details === 
npm notice name:          gitlabci-npm-artifactory                
npm notice version:       1.0.0                                   
npm notice filename:      gitlabci-npm-artifactory-1.0.0.tgz      
npm notice package size:  6.8 MB                                  
npm notice unpacked size: 21.5 MB                                 
npm notice shasum:        81be9defef61f0afaa9e9503c17b611f59c90bdb
npm notice integrity:     sha512-bbLIHqj3THLma[...]+UNMCLsnVSQsA==
npm notice total files:   9                                       
npm notice 
gitlabci-npm-artifactory-1.0.0.tgz
[Info] [Thread 2] Uploading artifact: /builds/ArielKJFrog/NPM-TEST/gitlabci-npm-artifactory-1.0.0.tgz
[Info] npm publish finished successfully.
$ ./jfrog rt bag gitlabci-npm-artifactory $CI_JOB_ID
[Info] Collecting git revision and remote url...
[Info] Collected git revision and remote url for gitlabci-npm-artifactory/72931109.
$ ./jfrog rt bp gitlabci-npm-artifactory $CI_JOB_ID
[Info] Deploying build info...
[Info] Build info successfully deployed. Browse it in Artifactory under https://arielk.jfrog.io/arielk/webapp/builds/gitlabci-npm-artifactory/72931109