Skip to content

RealJenkinsRule support for executeOnServer #637

@jglick

Description

@jglick

Currently JenkinsRule.executeOnServer does not work from RealJenkinsRule, since ClosureExecuterAction is registered as an extension from test code, which is ignored.

The following works but is not thread-safe:

@SuppressWarnings("deprecation")
static <V> V executeOnServer(JenkinsRule r, Callable<V> c) throws Exception {
    ClosureExecuterAction cea = new ClosureExecuterAction();
    r.jenkins.getExtensionList(RootAction.class).add(cea);
    r.jenkins.getActions().add(cea);
    try {
        return r.executeOnServer(c);
    } finally {
        r.jenkins.getExtensionList(RootAction.class).remove(cea);
        r.jenkins.getActions().remove(cea);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions