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

Better default for PodTemplateStep.label

    Details

    • Similar Issues:
    • Released As:
      1.17.0

      Description

      Various examples in documentation and tests either set a hard-coded label for the podTemplate step, which is a race condition waiting to happen, or use ugly Groovy scripting with UUID.randomUUID(). These would better be simplified to use the standard Jenkins environment variable BUILD_TAG, which is unique per build and is also meaningful to humans trying to debug label assignments and node provisioning:

      podTemplate(label: BUILD_TAG, containers: [containerTemplate(name: 'ubuntu', image: 'ubuntu', command: 'sleep', args: 'infinity')]) {
          node (BUILD_TAG) {
              container('ubuntu') {
                  sh 'whoami'
              }
          }
      }
      

      For Declarative, there is no good reason to force the user to define the label at all (see Declarative tests using label: '...'); KubernetesDeclarativeAgent.label could simply be defaulted to something such as BUILD_TAG.

        Attachments

          Issue Links

            Activity

            jglick Jesse Glick created issue -
            jglick Jesse Glick made changes -
            Field Original Value New Value
            Link This issue relates to JENKINS-57704 [ JENKINS-57704 ]
            Hide
            jglick Jesse Glick added a comment - - edited

            BUILD_TAG will not work, however, in cases where the job name is not a label K8s label. Thus this defaulting needs to use something like this, or perhaps simpler since the name could be any random string (it already gets uniquified) so long as it bears some resemblance to the job name.

            Show
            jglick Jesse Glick added a comment - - edited BUILD_TAG will not work, however, in cases where the job name is not a label K8s label. Thus this defaulting needs to use something like this , or perhaps simpler since the name could be any random string (it already gets uniquified ) so long as it bears some resemblance to the job name.
            Hide
            jglick Jesse Glick added a comment -

            Note that pod names default to label.

            Show
            jglick Jesse Glick added a comment - Note that pod names default to label .
            jglick Jesse Glick made changes -
            Remote Link This issue links to "Comment to PR 527 (Web Link)" [ 23145 ]
            jglick Jesse Glick made changes -
            Link This issue relates to JENKINS-51248 [ JENKINS-51248 ]
            jglick Jesse Glick made changes -
            Assignee Carlos Sanchez [ csanchez ] Jesse Glick [ jglick ]
            jglick Jesse Glick made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            jglick Jesse Glick made changes -
            Remote Link This issue links to "kubernetes #539 (Web Link)" [ 23224 ]
            jglick Jesse Glick made changes -
            Status In Progress [ 3 ] In Review [ 10005 ]
            jglick Jesse Glick made changes -
            Remote Link This issue links to "CloudBees-internal issue (Web Link)" [ 23225 ]
            vlatombe Vincent Latombe made changes -
            Status In Review [ 10005 ] Fixed but Unreleased [ 10203 ]
            Resolution Fixed [ 1 ]
            vlatombe Vincent Latombe made changes -
            Status Fixed but Unreleased [ 10203 ] Resolved [ 5 ]
            Released As 1.17.0

              People

              • Assignee:
                jglick Jesse Glick
                Reporter:
                jglick Jesse Glick
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: