简体   繁体   English

如何使用 Jenkins 中的作业参数或环境变量来归档工件?

[英]How to use job parameter or environment variable in Jenkins for archiving artifacts?

I have got a little issue with archiving artifacts using Jenkins我在使用 Jenkins 归档工件时遇到了一些问题

I would like to use a 'job parameter' (or environment variable) to archive the artifacts我想使用“作业参数”(或环境变量)来存档工件

I tried the following options in 'Files to archive' but nothing worked我在“要存档的文件”中尝试了以下选项,但没有任何效果

1)  **/${MODULE_NAME}/*.dll
2)  **/$MODULE_NAME/*.dll
3)  **/%MODULE_NAME%/*.dll
4)  **/$ENV:MODULE_NAME/*.dll

Kindly let me know whether there's any way to use 'job parameter' or 'environment variable' in Jenkins请告诉我是否有任何方法可以在 Jenkins 中使用“作业参数”或“环境变量”

I checked and you're doing that correctly (I tried to use **/${MODULE_NAME}/*.txt in Files to archive section). 我检查了一下,然后您所做的正确(我尝试在Files to archive部分中使用**/${MODULE_NAME}/*.txt )。 Here is my test configuration: 这是我的测试配置: 在此处输入图片说明 and 在此处输入图片说明

So, it's ok to have this error: 因此,可以出现此错误:

'**/${MODULE_NAME}/*.txt' doesn't match anything: '**' exists but not '**/${MODULE_NAME}/*.txt'

When I run the job everything is fine. 当我执行工作时,一切都很好。 In my case, console output is: 就我而言,控制台输出为:

Started by user admin
Building on master in workspace /var/jenkins_home/workspace/freestyle
[freestyle] $ /bin/sh -xe /tmp/jenkins6987280264619488185.sh
+ cd directory1/directory2/directory3
+ touch test.txt
+ echo 24
+ ls
test.txt
Archiving artifacts
Finished: SUCCESS

I recommend you to check other part of configuration and also check if your file is created in the right path. 我建议您检查配置的其他部分,并检查文件是否在正确的路径中创建。

I guess is not possible yet to expand variables, you must pre-parse the files before archiving.我猜还不可能扩展变量,您必须在存档之前预先解析文件。

JENKINS-5758詹金斯-5758

You can use the "Arhive the Artifacts" post-build-action, you just put the files that you will store from the workspace: 您可以使用“ Arhive Artifacts”构建后操作,只需将要从工作空间存储的文件放入即可:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从作业中设置环境变量并在jenkins的下一个作业中使用它? - How to set environment variable from a job and use it in next job in jenkins? 如何根据作业参数设置 Jenkins 环境变量? - How do I set a Jenkins environment variable based on a job parameter? Jenkins:将环境变量传递给作业参数 - Jenkins: Pass environment variable to the job parameter 如何为Jenkins作业使用“从其他项目复制工件”中的“运行参数”中的值? - How can I use the value from “Run Parameter” in “Copy artifacts from another project” for our Jenkins job? 了解詹金斯中的存档工件 - Understanding Archiving artifacts in jenkins 在Jenkins中归档工件,然后选择要部署到环境的工件 - Archiving artifacts in Jenkins and choosing which artifact to deploy to environment 如何在詹金斯中将参数作为环境变量从上游作业传递到下游作业? 无需对下游工作进行参数化 - How to pass parameter as environment variable from upstream job to downstream job in jenkins? without downstream jobs being parametrized 如何将环境变量传递给另一个作业 Jenkins - How to pass environment variable to another job Jenkins 在Jenkins管道的参数部分中使用环境变量 - Use environment variable in parameter section of Jenkins pipeline Jenkins(Hudson)用于归档构建工件的后端是什么? - What backend does Jenkins (Hudson) use for archiving build artifacts?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM