After a bit of trial with the Groovy init script for configuring namespaces, which technically works, the act of redeploying Jenkins and disrupting jobs to onboard a new application is undesirable and has us thinking about dynamically reconfiguring the openshift-sync plugin via a pod that discovers namespaces and calls out to Jenkins script console. The major problem is triggering GlobalPluginConfiguration.configChange() <https://github.com/jenkinsci/openshift-sync-plugin/blob/master/src/main/java/io/fabric8/jenkins/openshiftsync/GlobalPluginConfiguration.java#L248> such that the existing runnables are reset as it is a private method.
Has anyone successfully configured this outside of a Groovy init script such that it is reflected correctly in the Jenkins >> Manage >> Configure System and resets the existing runnable task? #1 via GlobalPluginConfiguration setter <https://github.com/jenkinsci/openshift-sync-plugin/blob/master/src/main/java/io/fabric8/jenkins/openshiftsync/GlobalPluginConfiguration.java#L153> and getter <https://github.com/jenkinsci/openshift-sync-plugin/blob/master/src/main/java/io/fabric8/jenkins/openshiftsync/GlobalPluginConfiguration.java#L106> import io.fabric8.jenkins.openshiftsync.GlobalPluginConfiguration; def plugin = Jenkins.instance.getDescriptor('io.fabric8.jenkins.openshiftsync.GlobalPluginConfiguration') plugin.setNamespace("A B C D ...") plugin.save() #2 via GlobalPluginConfiguration.configure(StaplerRequest, JSONObject) <https://github.com/jenkinsci/openshift-sync-plugin/blob/master/src/main/java/io/fabric8/jenkins/openshiftsync/GlobalPluginConfiguration.java#L116> import jenkins.model.Jenkins import io.fabric8.jenkins.openshiftsync.GlobalPluginConfiguration import net.sf.json.JSONObject import net.sf.json.JSONArray import org.kohsuke.stapler.Stapler import org.kohsuke.stapler.RequestImpl import javax.servlet.http.HttpServletRequest def httpServletRequest = [ getRequestURI: { null } ] as javax.servlet.http.HttpServletRequest def servletConfig = [ getServletContext: { Jenkins.getInstance().servletContext }, getInitParameter: { null }, getServletName: { "" } ] as javax.servlet.ServletConfig Stapler stapler = new Stapler() stapler.init(servletConfig) RequestImpl requestImpl = new RequestImpl(stapler, httpServletRequest, [] as java.util.List<org.kohsuke.stapler.AncestorImpl>, null) def plugin = Jenkins.getInstance().getDescriptor("io.fabric8.jenkins.openshiftsync.GlobalPluginConfiguration") plugin.configure(requestImpl, [ "namespaces": "A B C D ...", ] as JSONObject) On Thu, Aug 16, 2018 at 2:43 PM Gabe Montero <gmont...@redhat.com> wrote: > > > On Thu, Aug 16, 2018 at 2:37 PM Andrew Feller <afel...@bandwidth.com> > wrote: > >> Yeah, I think it's this one >> <https://trello.com/c/V1mtI7bi/1518-3-allow-the-use-of-environment-variables-to-specify-namespaces-sync-plugin-should-monitor-jenkinsintegrationpipelineintegration>. >> Depending on the level of effort, I might be able to potentially contribute >> on a fix for it. I didn't know if anyone has a workaround other than >> mounting a Groovy script for Jenkins to load. >> > > Yeah a groovy init script is the best workaround until the referenced RFE > happens. > > >> On Thu, Aug 16, 2018 at 1:41 PM Ben Parees <bpar...@redhat.com> wrote: >> >>> >>> >>> On Thu, Aug 16, 2018 at 10:52 AM, Andrew Feller <afel...@bandwidth.com> >>> wrote: >>> >>>> Is anyone familiar with overriding the openshift-sync plugin namespace >>>> property? >>>> >>>> I'm working to condense the Jenkins instances we have running with a >>>> central Jenkins running in OpenShift pulling BuildConfigs from remote >>>> namespaces. However, I rather not manually configure Jenkins >>>> openshift-sync plugin on the namespaces it should be monitoring and hoping >>>> there is a better way than crafting a Groovy script to be loaded by Jenkins >>>> on startup to override this. >>>> >>> >>> Pretty sure this has come up before and might even exist as an RFE >>> (namely the ability to set the list of namespaces to watch via an env var) >>> but i don't think anything has been implemented yet. Gabe would know for >>> sure. >>> >>> >>> >>>> >>>> Thanks! >>>> -- >>>> >>>> [image: BandwidthMaroon.png] >>>> >>>> Andy Feller • Sr DevOps Engineer >>>> >>>> 900 Main Campus Drive, Suite 500, Raleigh, NC 27606 >>>> <https://maps.google.com/?q=900+Main+Campus+Drive,+Suite+500,+Raleigh,+NC+27606&entry=gmail&source=g> >>>> >>>> >>>> e: afel...@bandwidth.com >>>> >>>> _______________________________________________ >>>> users mailing list >>>> users@lists.openshift.redhat.com >>>> http://lists.openshift.redhat.com/openshiftmm/listinfo/users >>>> >>>> >>> >>> >>> -- >>> Ben Parees | OpenShift >>> >>> >> >> -- >> >> [image: BandwidthMaroon.png] >> >> Andy Feller • Sr DevOps Engineer >> >> 900 Main Campus Drive, Suite 500, Raleigh, NC 27606 >> <https://maps.google.com/?q=900+Main+Campus+Drive,+Suite+500,+Raleigh,+NC+27606&entry=gmail&source=g> >> >> >> e: afel...@bandwidth.com >> > -- [image: BandwidthMaroon.png] Andy Feller • Sr DevOps Engineer 900 Main Campus Drive, Suite 500, Raleigh, NC 27606 e: afel...@bandwidth.com
_______________________________________________ users mailing list users@lists.openshift.redhat.com http://lists.openshift.redhat.com/openshiftmm/listinfo/users