History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: QB-3017
Type: Bug Bug
Status: Closed Closed
Resolution: Won't Fix
Priority: Major Major
Assignee: Robin Shen
Reporter: Vadim Volkov
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
QuickBuild

vars.getAll returns empty collection

Created: 20/Jul/17 06:41 AM   Updated: 22/Jul/17 01:09 AM
Component/s: None
Affects Version/s: 7.0.17
Fix Version/s: None

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown
Environment: java version "1.8.0_131", Ubuntu 16.04.2 LTS


 Description  « Hide
Following script outputs "All vars: []" to log instead of list of variable names and values
Configuration have several variables and they are accesible through vars.get(<name>).getValue()

groovy:
import com.pmease.quickbuild.variable.VariableWrapper
for (VariableWrapper var : vars.getAll()) {
    logger.info(var.getName())
    logger.info(var.getValue())
}
logger.info("All vars: " + vars.getAll())

 All   Comments   Work Log   Change History      Sort Order:
Robin Shen [20/Jul/17 11:49 PM]
vars.getAll() only returns variables actually used in a build. If you want to access variables defined in a configuration, call configuration.findVariables() which will return a list of Variable instance

Vadim Volkov [21/Jul/17 01:23 AM]
Using configuration.findVariables returns list of defined variables. I am still not clear what you mean in variables used?

I have a step with groovy script that uses variables from configuration, but vars.getAll returns empty collection. I have a repository that uses configuration variable in repository description, but vars.getAll returns empty collection. vars.getAll documentation looks confused because used is not mention. There are several examples everywhere also without mentioning it.

Anyway configuration.findVariables suits my needs. Thank you for reply.

Robin Shen [22/Jul/17 01:09 AM]
For instance if your build accesses a variable, like below:
echo ${vars.getValue("someVar")}

Then "someVar" will be considered "used", and will appear in vars.getAll().