bmustiata / jenny

Command line Jenkinsfile runner written in groovy. Does not need a Jenkins installation to run the Jenkinsfile.
BSD 3-Clause "New" or "Revised" License
91 stars 8 forks source link

Parameters values set manually are not used when updating bindings. #36

Closed bmustiata closed 6 years ago

bmustiata commented 6 years ago
def call(self) {
    def safeParameters = self.binding.getVariable("__safeParameters")

    safeParameters.each {
        // convert the booleans correctly
        try {
            def value = self.evaluate(it.arguments.name)

            if (it.symbol == 'booleanParam' && !(value instanceof Boolean)) {
                self.binding.setVariable(it.arguments.name, Boolean.valueOf(value))
            }
        } catch (Exception e) {
            self.binding.setVariable(it.arguments.name, it.arguments.defaultValue)
        }
    }
}

Since the params list is read at initialization time, this will populate the _global scope with the variables values. For some reason the self.evaluate(it.arguments.name) does not resolve them correctly, and does not use the current shell binding, so will result in always going with the defaultValue, which is not what we set as a parameter.