Closed quasarea closed 6 years ago
I'm not sure if that is possible for build step implementations. (At least, i don't know how)
What I mean that I have working pipeline code:
if (BuildAvoided) {
addBadge(icon: "/images/16x16/blue.png", text: queryResult)
} else {
addInfoBadge (queryResult)
}
and as you can see, addInfoBadge takes parameters directly, while addBadge requires named parameters. Both work fine without named parameters, when called with manager:
if (BuildAvoided) {
manager.addBadge("/images/16x16/blue.png", queryResult)
} else {
manager.addInfoBadge (queryResult)
}
so there is some inconsistency
This inconsistency that you mention is a feature of the framework. The difference is, that addInfoBadge has only one single argument. The implementation then takes this argument for the single parameter.
If you have more than one argument, the framework needs the keys for them. otherwise an IllegalArgument Exception is thown. See: https://github.com/jenkinsci/workflow-cps-plugin/blob/master/src/main/java/org/jenkinsci/plugins/workflow/cps/DSL.java#L532
Ok, thanks for explanation. Will use named arguments.
as described at https://jenkins.io/doc/pipeline/steps/badge/#addbadge-add-badge :
but calling
yields
named parameters works fine, but constructor with (string icon, string text, string id = null, string link = null) should be exposed - it works (such constructor when used via manager, i.e.: