[JIRA] (JENKINS-59632) Plugin does not respect the jenkinsUrl configuration from configuration-as-code

3 views
Skip to first unread message

rtyler@brokenco.de (JIRA)

unread,
Oct 2, 2019, 4:03:02 PM10/2/19
to jenkinsc...@googlegroups.com
R. Tyler Croy created an issue
 
Jenkins / Bug JENKINS-59632
Plugin does not respect the jenkinsUrl configuration from configuration-as-code
Issue Type: Bug Bug
Assignee: Unassigned
Components: kubernetes-plugin
Created: 2019-10-02 20:02
Environment: Jenkins 2.176.3, plugin version 1.19.1
Priority: Major Major
Reporter: R. Tyler Croy

It appears the the "Jenkins URL" configuration in the main configuration is not properly over-writable from the configuration as code plugin.

The configuration snippet below is always overwritten at runtime, it seems, with whatever the Kubernetes master Service IP turns out to be. In the case of my local testing of our Jenkins master image, which is not running in Kubernetes, after booting with the configuration below the "Jenkins URL" setting is `http://:`

---
jenkins:
  clouds:
  - kubernetes:
      connectTimeout: 5
      jenkinsUrl: "https://some-external-dns-entry/"

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

rtyler@brokenco.de (JIRA)

unread,
Nov 15, 2019, 12:21:02 PM11/15/19
to jenkinsc...@googlegroups.com
R. Tyler Croy commented on Bug JENKINS-59632
 
Re: Plugin does not respect the jenkinsUrl configuration from configuration-as-code

I have a workaround which I am using for now, which relies on the init.groovy.d/ support in Jenkins:

/*
 * This script helps work around an issue with the Jenkins Kubernetes plugin
 * which doesn't properly receive the configured `jenkinsUrl` on restart.
 *
 * The script is making an assumption that we can wait for a few seconds on
 * bootstrap before overwriting the URL on the object directly
 *
 * See: <https://issues.jenkins-ci.org/browse/JENKINS-59632>
 */
import jenkins.model.*
import org.csanchez.jenkins.plugins.kubernetes.*

/*
 * Spinning off a separate thread to do this work so this doesn't block the
 * bootstrap of the Jenkins master
 */
Thread.start {
    sleep 5000
    /*
     * On the off chance we have more clouds, this is looking for the
     * Kubernetes one only, and then setting the URL to what we have in our
     * environment defined as an override.
     */
    for (cloud in Jenkins.instance.clouds) {
        if (cloud.class == KubernetesCloud) {
            if (System.env.KUBERNETES_JENKINS_URL) {
                println "Overwriting the Kubernetes Jenkisn URL to: ${System.env.KUBERNETES_JENKINS_URL}"
                cloud.setJenkinsUrl(System.env.KUBERNETES_JENKINS_URL);
                Jenkins.instance.save();
            }
        }
    }
}
Reply all
Reply to author
Forward
0 new messages