I would like to create a Jenkins job where I am backing up and deploying specific databases to a remote MongoDB instance. I would like this assembly to be parameterized so that during the assembly the user selects MongoDB from the list of valid host names, and then, as soon as the user selects a valid database host name, the second choice of list parameters will be dynamically populated with all valid database names for these hostnames. Then, once the user selected the database name, which will be stored in the "DB" parameter, which can be passed to the "Run the shell" script assembly stage to perform the actual work.
My problem is that I need to execute the script method in the Jenkins Dynamic Parameter (Cascading) dynamic parameter, which will run a shell (or, ideally, python) script that will return a list of valid DB Names on the selected host. I canβt get the groovy script part of the plugin to execute shell commands on the local OS (for example, the βRun the shellβ build step).
Ideally, I would like to run something like this, where "MONGOHOST" is the first parameter selected by the user:
#!/usr/bin/env python from pymongo import MongoClient client = MongoClient('mongodb://${MONGOHOST}:27017/') choicelist = client.database_names() client.close()
I would like the choicelist to appear in such a way that they are populated as available options for the DB parameter.
How can I achieve this, especially since the Dynamic Choice parameter accepts only a groovy script and not its own python?
python dynamic parameters mongodb jenkins
perdurabo93
source share