[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Automating overriding of openshift-sync Jenkins plugin configuration

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() 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 and getter

import io.fabric8.jenkins.openshiftsync.GlobalPluginConfiguration;

def plugin = Jenkins.instance.getDescriptor('io.fabric8.jenkins.openshiftsync.GlobalPluginConfiguration')
plugin.setNamespace("A B C D ...")

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()

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 <gmontero redhat com> wrote:

On Thu, Aug 16, 2018 at 2:37 PM Andrew Feller <afeller bandwidth com> wrote:
Yeah, I think it's this one.  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 <bparees redhat com> wrote:

On Thu, Aug 16, 2018 at 10:52 AM, Andrew Feller <afeller 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.



users mailing list
users lists openshift redhat com

Ben Parees | OpenShift




Andy Feller    Sr DevOps Engineer

900 Main Campus Drive, Suite 500, Raleigh, NC 27606

e: afeller bandwidth com

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]