Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-51569

Use idleMinutes in declarative pipelines

    Details

    • Type: Improvement
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: kubernetes-plugin
    • Labels:
      None
    • Environment:
      Jenkins ver. 2.107.3
      kubernetes-plugin ver. 1.6.3
    • Similar Issues:

      Description

      We would like to use the option idleMinutes in declaratives pipelines.

      Indeed, we would like to reuse the created pod for other builds, since it takes some time to instantiate.

      We tried this, but were unsuccessful :

       

      agent {
        kubernetes {
          label 'mylabel'
          defaultContainer 'jnlp'
          yaml '''
      apiVersion: v1
      kind: Pod
      metadata:
       labels:
       some-label: some-label-value
      spec:
       containers:
       - name: jnlp
       image: my-docker.corp:42/jnlp:3.7-1-alpine
       args: 
       - ${computer.jnlpmac} ${computer.name}
       tty: true
       idleMinutes: 20
      '''

       

      Is there a way to do so ? If no, that would be a great feature !

      Thanks !

        Attachments

          Activity

          Hide
          csanchez Carlos Sanchez added a comment -

          you would need to put it at the same level as label and add a method to KubernetesDeclarativeAgent
          https://github.com/jenkinsci/kubernetes-plugin/blob/master/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesDeclarativeAgent.java

          But I don't think it would work because the defined agent should be there only for the duration of the declarative pipeline

          Show
          csanchez Carlos Sanchez added a comment - you would need to put it at the same level as label and add a method to KubernetesDeclarativeAgent https://github.com/jenkinsci/kubernetes-plugin/blob/master/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesDeclarativeAgent.java But I don't think it would work because the defined agent should be there only for the duration of the declarative pipeline
          Hide
          i351654 Tom Marcuzzi added a comment -

          I tested your suggestion and it worked !

          I made a pull request: Add idleMinutes to pod template in declarative pipeline

          Thanks !

          Show
          i351654 Tom Marcuzzi added a comment - I tested your suggestion and it worked ! I made a pull request: Add idleMinutes to pod template in declarative pipeline Thanks !
          Hide
          csanchez Carlos Sanchez added a comment -

          thanks!

          Show
          csanchez Carlos Sanchez added a comment - thanks!

            People

            • Assignee:
              csanchez Carlos Sanchez
              Reporter:
              i351654 Tom Marcuzzi
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: