npm - 我如何在 JFrog CLI 中以非管理员用户的身份使用带有 --build-name 和 --build-number 命令选项的 npm-install?
问题描述
描述
我正在尝试设置 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 多个依赖项。
如何获得与非管理员用户相同的结果?
解决方案
如果这有帮助,我曾尝试重现此行为,但无法重现。已使用 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
推荐阅读
- python - 如何将格式化句子数组传递给 Flask 模板?
- javascript - 当用户在地址栏 Angular 上单击输入时检测事件
- php - 在 Laravel 中更新大量条目的最佳方法
- powershell - 在 Windows 10 上通过 ssh 在 cygwin 上获得 rsync 的神奇组合
- google-cloud-firestore - 用户喜欢 Firestore 中的结构以避免高读取次数
- c# - “字符串 []”不包含“包含”的定义
- npm - npm 6.3.0 --only=prod install devDependencies 也
- c# - 需要来自 Json 字符串的所有唯一键名
- vba - 用户窗体自动调整请求宽度/高度的 80% 并更改纵横比
- javascript - 将文本发送到特定频道的命令