[plugin] Executors booking

21 views
Skip to first unread message

Tomasz Markiewicz

unread,
Feb 6, 2020, 8:10:43 AM2/6/20
to Jenkins Developers
Hi,

I was wondering if it is possible to "integrate" heavy-job-plugin functionality into pipeline projects.

The result I aim for is something (more or less) like this to be available from the pipeline:

bookExecutors(20) {
    sh 'make -j20`
}

Which should mark/reserve 20 executors (19 actually -- one would be used by make)
on the node on which make invocation takes place.

Currently I derived from org.jenkinsci.plugins.workflow.steps.Step,
so I can run my "plugin" directly from the pipeline. But I have no idea how to "reserve" or
"mark as busy" some executors.

Is it even possible?

I tried to add analogous JobProperty to the one defined in heavy-job-plugin [1] via:

    public boolean start() throws Exception {

        final StepContext context = getContext();
        final Job job = run.getParent();
        final Run run = context.get(Run.class);

        job.addProperty(...);

        context.newBodyInvoker().withCallback(BodyExecutionCallback.wrap(context)).start();
        return false;
    }

But it didn't work.

Any ideas on how I should attack the problem?

Thanks,

TGM

Refs:

Jesse Glick

unread,
Feb 7, 2020, 8:55:22 AM2/7/20
to Jenkins Dev
On Thu, Feb 6, 2020 at 8:10 AM Tomasz Markiewicz
<tomasz.g....@gmail.com> wrote:
> I was wondering if it is possible to "integrate" heavy-job-plugin functionality into pipeline projects.

Not easily. See JENKINS-41940. The non-Pipeline functionality relies
on a core API (`JobProperty.getSubTasks`) which I am guessing was
created for this express purpose. Pipeline actually does call this
API, but it is not useful in that context since executors are
allocated programmatically zero or more times via a step, as opposed
to traditional builds which are statically associated with one
executor. You would have to either duplicate all of `ExecutorStep`
with an added `weight` parameter, or find a way to cleanly inject this
subtask override into the existing implementation, or find an
alternative design that does not rely on subtasks.
Reply all
Reply to author
Forward
0 new messages