I have created one managed file(config file provider plugin) that i am using to populate the parameter values using active choice parameter, which is working fine.
Now, i want to update and save the content of managed file back to Jenkins, so that parameter values should be updated accordingly and to be available for subsequent job execution, and this i want to do in last stage of scripted pipeline.
Let me know if this is feasible and if yes, any ref of groovy logic, supported api calls etc.
You can mess with Jenkins instance and all its config via standard Jenkins internal APIs - however this will ONLY work in non-sandboxed mode and will have to be approved by admin. I would highly advise against doing this if not absolutely critical, as it is a dangerous thing - see if there is another way
Ok, then please suggest me alternate options, use case is per below which i am trying to solve.
I need to dynamically populate the parameter value by collecting details from remote system like cloud.
i have used active choice parameter and able to achieve that, but problem with this approach is that active choice groovy script execute on jenkins controller/controller, not on slaves which is already bundled with required cli/tools, hence it is manadatory to setup required cli/tools on controller to use them at the time execution, which is not i am looking for.
So, i decided to host file(managed file) Jenkins itself, refer it through active choice groovy(able to achive that), but i need to update and save it back to jenkins again, where i am struggling with.
Let me know if you any thoughts around this use case.
For one, all pipeline code executes on the controller, that said, the easy way to do it is to run the code wherever/however and write output to a JSON file on s3 or some web server, then fetch it from active choice or equivalent. If you REALLY want it to run at exact time the user clicks rather than in the background, write a quicky microservice that takes an HTTP call and returns the data you need.
That said, if you are relying on the user to enter data to make your CI work, it is no longer really CI, is it :-/