Have you tried configuration as code plugin?

On Mon, Aug 20, 2018, 15:54 Alex <alexandruiv...@gmail.com> wrote:

> I am trying to configure the kubernetes plugin by using groovy at startup.
>
> The problem that I have is that I can see the configuration in the
> "Configure System" menu, but it's not working unless i click on "Save"
>
> This is my groovy:
>
> import org.csanchez.jenkins.plugins.kubernetes.*
> import jenkins.model.*
>
> def jenkins_instance = Jenkins.instance
> def kubernetes = new KubernetesCloud('Kubernetes')
>
> // Configure Kubernetes Cloud
> kubernetes.setNamespace('jenkins')
> kubernetes.setJenkinsUrl(jenkins_instance.getRootUrl())
> kubernetes.setMaxRequestsPerHostStr('30')
> kubernetes.setConnectTimeout(30)
> kubernetes.setReadTimeout(30)
> kubernetes.setUsageRestricted(false)
>
> // Configure Jenkins Slave Container
> jenkins_slave_image = System.getenv('JENKINS_SLAVE_IMAGE').toString()
> def jenkins_container = new ContainerTemplate('jenkins-slave',
> jenkins_slave_image)
> jenkins_container.setTtyEnabled(true)
> jenkins_container.setName('jeknins-slave')
>
> // Configure Jenkins Slave Pods
> def jenkins_slave_pod = new PodTemplate()
> jenkins_slave_pod.setNamespace('jenkins')
> jenkins_slave_pod.setName('jenkins-slave')
> jenkins_slave_pod.setContainers([jenkins_container])
> jenkins_slave_pod.save()
>
> // Save Changes
> kubernetes.addTemplate(jenkins_slave_pod)
> jenkins_instance.clouds.removeAll(KubernetesCloud)
> jenkins_instance.clouds.addAll(kubernetes)
> jenkins_instance.save()
>
> Any thoughts on this?
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jenkinsci-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/85bd4d52-5083-4536-ae26-61370ac984a4%40googlegroups.com
> <https://groups.google.com/d/msgid/jenkinsci-users/85bd4d52-5083-4536-ae26-61370ac984a4%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CALHFn6MRvWO5uoVB-CJKuoAA_Qmwv_NZtkx1%2Buy4o3YbJViKow%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to