Unable to set pod retention for Jenkins Kubernetes plugin Groovy script.

19 views
Skip to first unread message

santhosh kumar

unread,
Apr 16, 2020, 3:48:00 AM4/16/20
to Jenkins Users
Trying to configure pod retention value  for Jenkins Kubernetes plugin using
groovy script.
kubernetes.setPodRetention(org.csanchez.jenkins.plugins.kubernetes.pod.retention.Podretention.Never())
method is failing to configure with below error :

Invalid value provided in main configuration No signature of method: static
org.csanchez.jenkins.plugins.kubernetes.pod.retention.PodRetention.Never()
is applicable for argument types: () values: []

tried configuring by using different values for the method:
kubernetes.setPodRetention(org.csanchez.jenkins.plugins.kubernetes.pod.retention.Never)

Error using the above value as well.

Please some one help me on this as i was struck with this from quite a long.

Below is the code:

import java.util.logging.Logger
import hudson.*
import hudson.model.*
import java.io.PrintWriter
import java.io.StringWriter
import jenkins.*
import jenkins.install.InstallState
import jenkins.model.*
import jenkins.util.xml.*
import javax.xml.xpath.*
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.impl.*
import com.cloudbees.plugins.credentials.common.*
import com.cloudbees.plugins.credentials.domains.*
import com.cloudbees.jenkins.plugins.sshcredentials.impl.*
import org.jenkinsci.plugins.plaincredentials.impl.*
import org.jenkinsci.plugins.docker.commons.credentials.*
import org.csanchez.jenkins.plugins.kubernetes.*
import org.csanchez.jenkins.plugins.kubernetes.pod.retention.PodRetention

KubernetesCloud kubernetes = new KubernetesCloud('test')
kubernetes.setServerUrl('http://test_url')
kubernetes.setMaxRequestsPerHostStr(20)
kubernetes.setPodRetention(org.csanchez.jenkins.plugins.kubernetes.pod.retention.PodRetention.Never())
kubernetes.setWaitForPodSec(90)

// documentation reference

 https://javadoc.jenkins.io/plugin/kubernetes/

// Method used
        setPodRetention(PodRetention podRetention)
Set the global pod retention policy for the plugin.

Can some let me know how to set the pod retention value using groovy with setPodRetention
Reply all
Reply to author
Forward
0 new messages