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

[Kubernetes Plugin] Jenkins templates with environment variables for parameters are evaluated just once

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • kubernetes-plugin
    • None
    • kubernetes 1.19.3 running on AWS

      kubernetes plugin version 1.27.3
    • 1.27.5

      When using kubernetes plugin 1.27.3, if there is a template that has a parameter/environment variable in the name field, that is evaluated once.  Subsequent usage of that template will not re-evaluate the parameter.  Rather, the first evaluation is always used.

       

      For instance, this is the below template in use. The parameter "${params.configmap}" is evaluated once, and never again on subsequent build using this template.
       

      agent {
              kubernetes {
                  label 'abc-jenkins-slave'
                  inheritFrom 'default'
                  yamlMergeStrategy merge()
                  yaml """
      apiVersion: v1
      kind: Pod
      metadata:
        namespace: cicd
        labels:
          some-label: some-label-value
        annotations:
          iam.amazonaws.com/role: arn:aws:iam::****:role/k8s-jenkins
      spec:
        containers:
        - name: soapui
          image: ****.dkr.ecr.us-east-1.amazonaws.com/abc:latest
          imagePullPolicy: Always
          command:
          - cat
          tty: true            
          securityContext:
            runAsUser: 1000
            runAsGroup: 1000
          resources:
            limits:
              cpu: 512m
              memory: 512Mi
            requests:
              cpu: 512m
              memory: 512Mi
          volumeMounts:
            - mountPath: /opt/abc/conf
              name: vol-0
        volumes:
        - name: vol-0
          configMap:
            name: ${params.configmap}
        tolerations:
        - key: dedicated
          operator: Equal
          value: jenkins
          effect: NoSchedule
        envFrom:
          - configMapRef:
              name: cred-properties
       
      """
              }
          }
      

       

            Unassigned Unassigned
            mmerrill3 Michael Merrill
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: