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

RealJenkinsRule support for executeOnServer #637

Open
jglick opened this issue Aug 11, 2023 · 0 comments
Open

RealJenkinsRule support for executeOnServer #637

jglick opened this issue Aug 11, 2023 · 0 comments

Comments

@jglick
Copy link
Member

jglick commented Aug 11, 2023

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);
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant