[英]How to include version number in JFrog CLI when publishing NPM package?
I've been working with the JFrog CLI tool a lot lately to upload our NPM package to our company artifactory which is working fine, however it requires a bit of "ugly" solutions with manual renaming in our GitHub actions pipeline among other things to get it to work as I want it to and I have one problem left before I can be happy with the uploading process.我最近一直在使用 JFrog CLI 工具来将我们的 NPM package 上传到我们公司的工件,这工作正常,但是它需要一些“丑陋”的解决方案,在我们的 ZD3B7C913CD04EBFEC0 管道中手动重命名以获取其他操作等它可以按我的意愿工作,但在我对上传过程感到满意之前,我还有一个问题。
The issue is that the.tgz file that gets uploaded to the artifactory isn't including the version in the file name so instead of being called file-name-1.0.0.tgz it's just file-name.tgz .问题是上传到工件的 .tgz 文件不包括文件名中的版本,因此它不是被称为file-name-1.0.0.tgz它只是file-name.tgz 。 This is creating issues because we don't have access to the older versions of our package on the artifactory.这会造成问题,因为我们无法访问工件上旧版本的 package。
Currently our pipeline in GitHub actions looks like this (summarized):目前我们在 GitHub 动作中的管道看起来像这样(总结):
(runs on linux virtual machine with access to our npm registry) (在 linux 虚拟机上运行,可以访问我们的 npm 注册表)
Once this workflow is finished, a second workflow is triggered to upload to the JFrog artifactory, using a self hosted linux runner with credentials for the artifactory.此工作流完成后,将触发第二个工作流上传到 JFrog 工件,使用带有工件凭据的自托管 linux 运行器。
- name: Create version string variable
run: |
PACKAGEVERSION=`jq -r .version package/package.json`
echo $PACKAGEVERSION
mv package-a.tgz "package-a-${PACKAGEVERSION}.tgz"
jf rt u "package-a-${PACKAGEVERSION}.tgz" "path/to/upload/directory/package-a-${PACKAGEVERSION}.tgz"
And then it downloads the other package and does the same thing.然后它下载另一个 package 并做同样的事情。
On the artifactory it doesn't show the version in the.tgz file name, instead it's just called package-a-.tgz so something in the renaming step goes wrong and I can't find a solution for it, even though I've tried many different approaches to this.在工件上,它没有在 .tgz 文件名中显示版本,而只是称为package-a-.tgz所以在重命名步骤中出现了问题,我找不到解决方案,即使我'为此尝试了许多不同的方法。
I'm also aware that the JFrog CLI has npm support built in, however we can't use it in our pipeline because of the credentials required, or at least I don't know how.我也知道 JFrog CLI 内置了 npm 支持,但是由于需要凭据,我们不能在管道中使用它,或者至少我不知道如何使用。
I'm very close to getting it to work as we want, it's just this short renaming that's not working out.我非常接近让它按照我们的意愿工作,只是这个简短的重命名没有成功。 Any help is very much appreciated.很感谢任何形式的帮助。 Thank you谢谢
My guess is that your PACKAGEVERSION
variable is out of scope, and is empty in the stages of renaming and upload.我的猜测是您的PACKAGEVERSION
变量超出了 scope,并且在重命名和上传阶段为空。 Did you try to configure it at the workflow level?您是否尝试在工作流级别对其进行配置?
https://docs.github.com/en/actions/learn-github-actions/environment-variables https://docs.github.com/en/actions/learn-github-actions/environment-variables
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.