Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in sandbox for default groovy static methods #177

Merged
merged 4 commits into from
Feb 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,17 @@ import java.lang.reflect.Method
@Override
boolean permitsStaticMethod(Method method, Object[] args){
Class receiver = method.getDeclaringClass()

Class receivingClass
if (args.size()){
receivingClass = args[0].getClass()
}

boolean a = permittedReceivers.collect{ r -> receiver in r }.contains(true)
boolean b = receiver.getName() in permittedReceiverStrings
return (a || b)
boolean c = args.size() && permittedReceivers.collect{ r -> receivingClass in r }.contains(true)
boolean d = args.size() && receivingClass.getName() in permittedReceiverStrings
return (a || b || c || d)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,26 @@ class TemplateBindingRegistrySpec extends Specification{
jenkins.assertLogContains("step: A", run)
}

def "GitHub #170 check namespaced environment"(){
given:
def run
WorkflowJob job = TestUtil.createAdHoc(jenkins, config: """
application_environments{
dev{
custom_field = "whatever"
}
}
""", template: 'println "custom_field is ${jte.application_environments["dev"].custom_field}"'
)

when:
run = job.scheduleBuild2(0).get()

then:
jenkins.assertBuildStatusSuccess(run)
jenkins.assertLogContains("custom_field is whatever", run)
}

@Ignore
def "Namespaced Default Step invoked"(){
given:
Expand Down