jenkinsci / plasticscm-plugin

A plugin for Jenkins to be able to use Plastic SCM
MIT License
16 stars 31 forks source link

Polling can be done on the controller, without any workspace #43

Closed Kalmalyzer closed 2 years ago

Kalmalyzer commented 2 years ago

We have recently begun the Plastic SCM plugin together with on-demand provisioned agents via the Google Compute Engine plugin. This works well, except that activating the "Poll SCM" feature results in errors. This is because the Plastic SCM plugin's polling currently is implemented to require a workspace. Polling also remembers which agent was used for the previous build, and tries to re-use that agent. This does not work well with on-demand provisioned agents.

This PR moves polling over to the controller instead.

Good:

Bad:

The P4 plugin has introduced polling on the master as an option.

The Git plugin has a "fast remote polling" feature, and can poll on the controller for single-branch workspaces, but not for multibranch scenarios AIUI.

I have tested this implementation on a setup with the controller on Kubernetes and agents provisioned via the GCE plugin. Both were running Linux at the time. I haven't tested with other OSes.

What do you think - do you approve of this in its current form? Would you prefer to have this to be opt-in? If so, would you prefer a per-job or a plugin-wide setting?

Kalmalyzer commented 2 years ago

Breaking existing installations is not a good idea. I have made this opt-in per-project.

image

One thing to note, if/when testing this: when you have a pipeline job, then the polling settings are taken from the last build performed. If you change configuration (either selector, or Poll on controller) for an existing job, then you need to trigger a build once before the changes will take effect for polling. Restarting Jenkins makes no difference. To confirm this, add some debug prints to the PlasticSCM constructor + PlasticSCM.requiresWorkspaceForPolling(). It's a built-in Jenkins behavior.

I have tested the new version both with freestyle and pipeline jobs. Linux controller + linux agent. I have focused on testing the new "poll on controller" flow, not the prior "poll on agent" flow.

This looks good to me now. What do you think?

mig42 commented 2 years ago

Hi @Kalmalyzer !

Thank you so much for your contribution. I think your proposal is really interesting and provides value to all users of our plugin. I like that you decided to make it opt-in to avoid issues with existing setups.

There are two things I'd like to address before merging this PR:

Thanks!

Kalmalyzer commented 2 years ago

I have tested this with a Windwos controller and confirmed that it works.

Also, I have updated the first screenshot in README.md + written a text section on the "Poll on controller" setting.

Will this do?

mig42 commented 2 years ago

Yes, it looks good to me! Thank you for your contribution! 😄