gpt4 book ai didi

jenkins - Jenkins 中的文件参数上传文件丢失

转载 作者:行者123 更新时间:2023-12-05 02:57:57 47 4
gpt4 key购买 nike

Jenkins 构建中的每个文件参数“帮助文本”,

Accepts a file submission from a browser as a build parameter. The uploaded file will be placed at the specified location in the workspace, which your build can then access and use. This is useful for many situations, such as:

  • Letting people run tests on the artifacts they built.
  • Automating the upload/release/deployment process by allowing the user to place the file.
  • Perform data processing by uploading a dataset.

The name of the submitted file is available in the environment variable whose name is the same as file location. For example, if you set the file location to be abc.zip, then ${abc.zip} would give you the original file name passed from the browser (such as my.zip.) The name will not include the directory name portion.

File upload is optional. If a user chooses not to upload anything, Jenkins will simply skips this parameter and will not place anything (but it also will not delete anything that's already in the workspace.)

和“文件位置”

Specifies the location, relative in the workspace, where the uploaded file will be placed (for example, like "jaxb-ri/data.zip")

按示例简单上传 zip 文件 - 似乎无法在任何地方上传文件 - 既不在 Workspace 中,也不在某个临时目录下。如何找到文件和/使用它?

这是尝试文件上传的简单管道..

properties(
[
parameters(
[ file(name: "file1", file: "file1.zip", description: 'Choose path to upload file1.zip from local system.') ]
)
]
)

node {
stage("Upload File") {
sh '''
ls -lrt
ls ${file1.zip} ${file1} file1.zip
'''
}


}

以及在控制台日志中观察到的相应运行错误。

[Pipeline] {
[Pipeline] stage
[Pipeline] { (Upload File)
[Pipeline] sh
[testSh] Running shell script
+ ls -lrt
total 0
Workspacedir///testSh@tmp/durable-ba40512f/script.sh: line 4: ${file1.zip}: bad substitution
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE

已按照此尝试 Groovy 建议(多种方式):Fetching binary or zipped uploaded files in Jenkins - Windows cannot open the folder . The Compressed(zipped) Folder is invalid ,但没有成功完成这项工作。

最佳答案

由于在脚本化管道中使用文件参数的限制,一个简单的自由式工作看起来可以解决问题:(。

我现在将继续使用它并继续处理下游依赖项或类似的消费上传工件。

enter image description here

有了这个,它只上传文件并且不会篡改文件大小和/它的内容:)

在可访问性方面,它是由 ${paramNameDefined} 获取的。

在 execute shell build type 下,我们可以像上面那样放置 ${file1} 来完成获取文件的技巧..

所以这里是运行上述自由风格作业的输出!

Copying file to file1
[sharedspace] $ /bin/sh -xe /tmp/hudson3237344085461334672.sh
+ ls file1.zip
file1.zip
Finished: SUCCESS

关于jenkins - Jenkins 中的文件参数上传文件丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59500141/

47 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com