[英]How to add config file for config file provider plugin with groovy script in jenkins
I am using Job DSL in Jenkins. 我在詹金斯(Jenkins)使用Job DSL 。 There is a seed job that generates some files that should be shared across other jobs that could run on different nodes. 有一个种子作业可生成一些文件,这些文件应在可以在不同节点上运行的其他作业之间共享。 If the files were not generated, the config files provider plugin could be used for this task. 如果未生成文件,则配置文件提供程序插件可用于此任务。 However I need the files to be dynamic so that no Jenkins UI interaction is needed. 但是,我需要文件是动态的,以便不需要Jenkins UI交互。
Is it possible to add a file to the plugin with a groovy script? 是否可以使用常规脚本向插件添加文件?
The only other option I could think of was to record the UI interaction and let a script replay it with modified data. 我唯一想到的其他选择是记录UI交互,并让脚本使用修改后的数据重播。 In case of a more secured Jenkins this would also require to get authentication and CSRF tokens right. 如果Jenkins安全性更高,则还需要正确获取身份验证和CSRF令牌。
You can use Job DSL to create config files that are managed by the Config File Provider plugin: 您可以使用Job DSL创建由Config File Provider插件管理的配置文件:
configFiles {
customConfig {
id('one')
name('Config 1')
comment('lorem')
content('ipsum')
providerId('???')
}
}
See https://github.com/jenkinsci/job-dsl-plugin/wiki/Job-DSL-Commands#config-file 参见https://github.com/jenkinsci/job-dsl-plugin/wiki/Job-DSL-Commands#config-file
When you are using job-dsl you can read in data from anywhere that the Groovy runtime can access. 使用job-dsl时,您可以从Groovy运行时可以访问的任何位置读取数据。
You could store shared config in a hard coded variable in your script itself. 您可以将共享配置存储在脚本本身的硬编码变量中。
You could inject the data via a Jenkins parameter to your seed job. 您可以通过Jenkins参数将数据注入种子作业。
You could retrieve the data from a file in the git repo where your store your seed job. 您可以从git存储库中存储种子作业的文件中检索数据。
You could retrieve the data from a database, REST API. 您可以从数据库REST API中检索数据。
etc etc. 等等等
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.