简体   繁体   English

如何在詹金斯中使用groovy脚本为配置文件提供者插件添加配置文件

[英]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.

相关问题 奴隶中的Jenkins配置文件提供程序插件 - Jenkins config file provider plugin in a slave Jenkins 配置文件提供程序插件如何工作? - How does the Jenkins config file provider plugin work? 如何从 Jenkins 中的配置文件(groovy 脚本)中读取值? - How to read value from config file (groovy script) in Jenkins? 如何使用配置文件提供程序插件从 Jenkins 管道内的配置文件中读取属性 - How to read property from config file inside Jenkins pipeline using Config File Provider Plugin 如何以编程方式配置“配置文件提供程序插件” - How to configure “Config File Provider Plugin” programatically 在 jenkins groovy 脚本中读取配置文件以获取构建参数 - Read Config file in jenkins groovy script for build parameters Jenkins中的配置文件管理插件 - Config File Management plugin in Jenkins 如何在每个作业中从 config-file-provider 插件设置 Jenkins 配置(默认) - How can I set Jenkins configuration from config-file-provider plugin in every job (per default) 如何在 Jenkins 中使用配置即代码插件配置 config-file-provider 文件 - How to configure config-file-provider files using configuration-as-code plugin in Jenkins Email 扩展插件未加载通过配置文件提供程序插件添加的 groovy 模板 - Email Extension Plugin is not loading groovy template added via Config File Provider Plugin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM