当前位置: 首页 > 知识库问答 >
问题:

在JFrog CLI中,我如何作为非管理员用户使用带有--build name和--build number命令选项的npm安装?

仲阳朔
2023-03-14

我正在尝试设置JFrog的artiFactory Pro(v 6.0.1)来存储和缓存我的项目的依赖项。我想使用JFrog CLI收集并将npm-build信息发布到artiFactory,就像这篇(https://jfrog.com/blog/npm-flies-with-jfrog-cli/)博文中描述的那样,但我希望能够以非管理员用户的身份进行。

artiFactory包含一个名为npm的虚拟存储库,它是本地(名为npm-local)和远程(名为npm-Remote)存储库的集合。

有两个用户:一个叫admin的用户有管理员权限,另一个叫developer的用户没有管理员权限。

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

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

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

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

[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.

当我继续

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

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

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

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个依赖项。

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

共有1个答案

张华池
2023-03-14

如果这有帮助的话,我已经尝试重现此行为,但未能成功。我已使用CLI与非管理员用户成功构建和发布(请参阅下面的构建日志)。

在您的情况下,可以通过在debug上运行JFrog CLI来调试它。

$ 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
 类似资料:
  • 我正在为我的考试创建一个Java项目。该项目要求我使用面向对象编程来做一个类似groupon的程序。它要求我实现一个销售打折产品的程序。我有假期,有饭局,有正常对象。我决定创建一个超类产品,然后扩展它,创建其他三个类,晚餐、假日和对象。但是它还要求我管理产品目录,让每个产品都有一个唯一的标识符,我该怎么做呢?即使我创建了一个Catalog类,用一个ArrayList管理产品,我怎么能给每个元素添加

  • 我一直在拼命地尝试使用Node.js安装模块,但它总是无法使用NPM获取包。 我以Administrator身份登录,并使用带有“Run as Administrator”的PowerShell/cmd。我的注册表也有问题,所以我使用了npm set registry http://registry.npmjs.org/

  • 我正在中创建路由。我正在为仪表板创建路由。 用户登录并获取 通过发送令牌,用户可以访问与用户相关的一些路由(编辑、删除、注销路由等) 但是对于管理员,我想创建可以查看用户列表、编辑或删除用户、检查用户注销时间的路由。我还设置了表中的标志,以识别用户或管理员 如何在后端验证管理员的路由?

  • 问题内容: 我正在按照此文档进行安装,并与命令混淆: 我知道“ ”命令只是返回成功状态代码,但是我如何理解该命令中的角色? 问题答案: 运行并因此创建一个新容器(即使终止)仍然保留所生成的容器图像和元数据,这些图像和元数据仍然可以链接到该容器。 因此,在运行时,您实际上是在创建一个用于存储目的的新容器并运行最简单的方法。 在Docker 1.5中引入了命令,因此我相信您现在可以“创建”容器而不会混

  • 有人能解释一下为什么我在检索选项'-x'时遇到困难(见下文)? 我必须逃避一些角色吗? 除此之外: 工作原理: 但这不是: 这是我的package.json档案 npm运行a的结果: npm运行b的结果 这2个文件a.js和b.js是一样的。只是a.js使用es6模块和b.js通用模块

  • 问题内容: 我正在尝试获取Django Admin界面来显示有关我的个人资料的信息。它显示我的所有用户,但不显示个人资料信息。我不太确定如何使它正常工作。 我在Google快速搜索后找到了以下代码: 但是,我认为它没有用。当我登录到管理页面时,我看到“用户”,“组”和“站点”。我单击用户,然后看到所有用户的列表,但没有任何个人资料的迹象。单击某个用户会显示有关该用户的信息,但仍然没有个人资料信息。