如何从命令行上传文件作为 jenkins 中的文件参数 [英] How to upload file from command line as file parameter in jenkins
本文介绍了如何从命令行上传文件作为 jenkins 中的文件参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在 Jenkins 的命令行中使用字符串参数触发构建:
I am triggering builds with string parameters from the command line in Jenkins with:
curl http://jenkins:8080/job/Build/buildWithParameters?PARAM=value&token=token
我现在想从命令行使用文件作为文件参数来触发构建.
I now want to trigger a build with a file as a file parameter from the command line.
例如,如果我的项目构建 main.c,那么我希望能够触发构建并从命令行上传我的 main.c.
For example if my project builds main.c then I would like to be able to trigger a build and upload my main.c from the command line.
这可能吗?
推荐答案
这在 中有描述Jenkins 远程访问 API 页面:
This is described in the Jenkins Remote access API page:
curl http://jenkins/job/$JOB_NAME/build -F file0=@PATH_TO_FILE -F json='{"parameter": [{"name":"FILE_LOCATION_AS_SET_IN_JENKINS", "file":"file0"}]}'
请注意,您需要使用 URL/build 而不是/buildWithParameters
Note that you need to use the URL /build instead of /buildWithParameters
这篇关于如何从命令行上传文件作为 jenkins 中的文件参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文