读取jenkins groovy脚本中的配置文件以获取构建参数 [英] Read Config file in jenkins groovy script for build parameters

查看:585
本文介绍了读取jenkins groovy脚本中的配置文件以获取构建参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个参数选择列表.选择列表中的值基于登录jenkins的用户.例如,一个学生选择了数学科学和商业学科,那么他应该能够在选择下拉菜单中看到自己的学科.

I have a choice list for a parameter. The values in choice list is based on user who logs in jenkins. For example a student opts for subjects maths science and commerce, he should be able to see his own subjects in the choice drop down.

我在json文件中对每个学生及其注册主题进行了映射.我使用配置文件提供程序插件在jenkins中引用了此文件.现在,我应该如何在选择参数中通过groovy脚本加载此配置文件.我正在使用扩展选择参数

I have the mapping of each student with their enrolled subject in a json file. I used Config File Provider plugin to refer this file in jenkins. Now how should I load this configuration files through groovy script in the choice parameters. I am using Extended Choice Paremater and Active Choice Parameter plugin

推荐答案

我使用以下groovy脚本从groovy脚本访问添加的配置文件.看看是否有帮助

I use the below groovy script to access added config files from groovy script. See if it helps

import org.jenkinsci.plugins.configfiles.GlobalConfigFiles
import org.jenkinsci.lib.configprovider.model.Config;
Config config = GlobalConfigFiles.get().getById("Your config file ID here")
println(config.content)`

这篇关于读取jenkins groovy脚本中的配置文件以获取构建参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆