首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在JFrog CLI中以非管理用户的身份使用npm-install with --build和--命令选项?

如何在JFrog CLI中以非管理用户的身份使用npm-install with --build和--命令选项?
EN

Stack Overflow用户
提问于 2018-06-06 08:19:17
回答 1查看 1.3K关注 0票数 0

描述

我正在尝试设置JFrog的Artifactory Pro (v6.0.1)来存储和缓存我的项目的依赖项。我想使用JFrog CLI收集和发布npm构建信息,就像在这个(https://jfrog.com/blog/npm-flies-with-jfrog-cli/)博客文章中描述的那样,但是我希望能够作为一个-admin用户来完成它。

设置

Artifactory包含一个名为npm的虚拟存储库,它是一个本地存储库(命名为npm)和一个远程存储库(命名为named)的集合。

有两个用户:具有管理权限的名为admin的用户和没有管理访问权限的名为developer的用户。

JFrog CLI的配置:

代码语言:javascript
运行
复制
# 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

我在做什么

对于这个测试,我尝试构建简单的节点-js-react npm -app (https://github.com/jenkins-docs/simple-node-js-react-npm-app),并使用以下JFrog CLI命令将其发布到Artifactory中的本地npm存储库:

代码语言:javascript
运行
复制
jfrog rt npm-install npm \
    --build-name=simple \
    --build-number=1.0.0 \
    --server-id=rt_dev

这会在命令执行之前产生以下错误(如果忽略npm阶段的错误):

代码语言:javascript
运行
复制
[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.

当我继续

代码语言:javascript
运行
复制
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

新发布的工件具有零依赖关系。

如果发布方式与管理员相同

代码语言:javascript
运行
复制
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

我有超过1000个依赖项。

如何获得与非管理员用户相同的结果?

EN

回答 1

Stack Overflow用户

发布于 2018-06-06 17:15:38

如果这有帮助的话,我试着复制这种行为,但没有做到。已经成功地使用CLI与非管理用户一起构建和发布(请参阅下面的构建日志)。

在您的示例中,您可以通过在JFrog上运行它来调试调试 CLI。

代码语言:javascript
运行
复制
$ 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: gitlabci-npm-artifactory@1.0.0
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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50715493

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档