|
|
|
[
Permlink
| « Hide
]
Robin Shen [05/Feb/23 12:34 AM]
Variables are saved together with configuration as binary data in database. However they can be printed into log via groovy scripts. Do you want to list all of them for all configurations?
Hi Robin, there is one variable "farm_blackduck_project_name" which actually contains the blackduck project name for security scanning. Some of the blackduck projects are already crossed the limit of number of Scans but they are still configured in several workflows. If we keep using them in our workflows, our build will fail. Hence, we want to list down all the workflows with such projects. Could you please share more details about table name and database name for this? I want to run some queries and sort out this data for our quick action.
I hope, I have explained the requirement why I am looking out for table & database name. Please let me know if you need more information.
Variables are saved in column qb_variables in table qb_configuration. The database name can be checked by examining "conf/hibernate.properties" under QB server directory. However you can not query the variables directly with SQL as all variables defined in a configuration are saved in a serialized binary form. However you can do that by creating a configuration, with a step running below groovy script:
groovy: for (eachConf in system.configurationManager.getAll()) { logger.info("Variables defined in configuration: " + eachConf.pathName); for (eachVar in eachConf.getVariables()) { logger.info(eachVar.name + ":" + eachVar.value); } } You may modify the script to filter variable names to print those you wanted. Hi Robin,
Many thanks for sharing this groovy script. We will work on it and update you. Regards, Nitin Hi Robin,
We have good news here. We are able to fetch all the required data from the variables using the Groovy script provided by you. I have 2 more queries. Would be great if you can help us here: 1) Using the above groovy script, we are able to fetch the project details now from variables values. As some of the projects are become obsolete, we need to replace them with the new project details. By going to each and every workflow and update them manually would be tedious task and will take a lot of time. Is there any way, we can achieve this in easy manner? 2) We have one overridden step in all the workflows which can't be inherited from root. In this step, we are using one of the jar file in our command. The version of the jar file is changed, and we need to update all the workflows. Could you please advise how can we do it in best feasible way? Thanks in advance Regards, Nitin Hi Nitin,
I am vendor of QuickBuild, and do not know details of your setup. I guess your work can be achieved by inspecting variable value, change it as necessary and get it saved like below: groovy: import com.pmease.quickbuild.migration.VersionedDocument; for (eachConf in system.configurationManager.getAll()) { logger.info("Variables defined in configuration: " + eachConf.pathName); for (eachVar in eachConf.getVariables()) { def confChanged = false; if (eachVar.value.contains("some special string")) { eachVar.setValue("new value"); confChanged = true; } } if (confChanged) system.configurationManager.save(eachConf); } To inspect step and save it: groovy: for (eachConf in system.configurationManager.getAll()) { logger.info("Variables defined in configuration: " + eachConf.pathName); var confChanged = false; for (eachStep in eachConf.getSteps()) { if (eachStep.name.contains("some string")) { // you may also check other setting of the step depending on step type eachStep.description = "some new string"; // this is a demo, change other settings as necessary eachConf.stepDOMs.put(eachStep.name, VersionedDocument.fromBean(eachStep)); confChanged = true; } } if (confChanged) system.configurationManager.save(eachConf); } Hi Robin,
Thanks again for your help. Unfortunately, this didn't work for us this time. Could you please let us know if you have any documentation somewhere on these methods, steps that we are trying to use in above Groovy script? Would like to explore it more. Thanks for your help. Regards, Nitin Hi Nitin,
You may check properties of different step types here: https://build.pmease.com/download/5646/html/Javadoc/com/pmease/quickbuild/stepsupport/Step.html Hi Robin,
We have implemented the code to change variable value under specific workflow. But getting error as "This operation does not allowed on agent side". Do you have resolution on this. Also we want to change the node assignment rule for master server configuration. Is there any special configuration needs to be done from server side for this. Regards, Rani Any script changing configuration setting including variables need to run at server side. Just configure the step to run on QB server.
To change node assignment rule of master step of a configuration, please use below script (should also run on QB server): groovy: import com.pmease.quickbuild.migration.VersionedDocument; var confToEdit = system.configurationManager.get("path/to/some/configuration"); var stepToEdit = confToEdit.getStep("master"); stepToEdit.setNodeMatcher(...); // pass in appropriate node matcher here confToEdit.stepDOMs[stepToEdit.name] = VersionedDocument.fromBean(stepToEdit); system.configurationManager.save(confToEdit); Hi Robin,
We might have some restrictions on running the build on master server. we searched for other option but didn't managed to get through. Do you have any option instead of running them on master. Unfortunately there is no option to run this on agent. You may create a child step running on server specificially for this purpose.
|