Anshu Kumar
Anshu Kumar

Reputation: 17

Read Config file in jenkins groovy script for build parameters

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.

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

Upvotes: 2

Views: 2754

Answers (1)

Bablu
Bablu

Reputation: 326

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)`

Upvotes: 2

Related Questions