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

Kubernetes agent environment not working with Git Parameter branch variable in SCM

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Blocker Blocker
    • kubernetes-plugin
    • None

      When using Git Parameter variable (ex ${BRANCH}) git checkout can be made in any "phisical node" but branch variable is not recognize by  any kubernetes agent, but if a string is used instead checkout is meade in kubernetes properly.

      JOB CONFIG

      1) Git Parameter configuration in job

      2) SCM configuration

      FAILED PIPELINE LOGS

      1) Correct SCM in 'master' label \\{_}Stage => Prepare\\{_}, ${BRANCH} variable is highlighted

      (pipeline code block)

      Branch was clone fine

      2) When trying to clone inside kubernetes environment ${BRANCH} is not recognized \\{_}Stage =>\\{_} \\{_}Build PHP test image\\{_}. Variable is highlighted, values is not recognized (seems treated as string).

      (pipeline code block)

      SUCCESS PIPELINE LOGS

      If the needed branch is hardcoded instead of the Git Parameter variable, checkouts work fine even in kubernetes environment

      1) SCM configuration

      2) Kubernetes agent/pod is created and checkout is performed inside, branch name is now correct (highlighted) \\{_}Stage =>\\{_} \\{_}Build PHP test image\\{_}

      • Why is the Git Parameter variable not recognized by kubernetes?
      • How can we pass that variable to kubernete-pligin?

      Could you help on this? Thanks in advance

      Regards!

      PS: This is the kubernetes agent definition

      kaniko-pod-definition.yaml

      (Also attahced)

       

          [JENKINS-71816] Kubernetes agent environment not working with Git Parameter branch variable in SCM

          David created issue -
          David made changes -
          Attachment New: kaniko-pod-definition.yaml [ 61008 ]
          Attachment New: image-2023-08-11-18-04-59-450.png [ 61009 ]
          Description Original: When using Git Parameter variable (ex ${BRANCH}) git checkout can be made in any "phisical node" but branch variable is not recognize by  any kubernetes agent, but if a string is used instead checkout is meade in kubernetes {{properly.}}

          *JOB CONFIG*

          1) Git Parameter configuration in job

          !image-2023-08-11-17-19-47-664.png!

          2) SCM configuration

          !image-2023-08-11-17-20-44-031.png!

          *FAILED PIPELINE LOGS*

          1) Correct SCM in 'master' label [{_}Stage => Prepare{_}], ${BRANCH} variable is highlighted

          !image-2023-08-11-17-28-13-417.png!

          (pipeline code block)

          !image-2023-08-11-17-31-36-824.png!

          Branch was clone fine

          2) When trying to clone inside kubernetes environment ${BRANCH} is not recognized [{_}Stage =>{_} {_}Build PHP test image{_}]. Variable is highlighted, values is not recognized (seems treated as string).

          !image-2023-08-11-17-37-56-019.png!

          *SUCCESS PIPELINE LOGS*

          If the needed branch is hardcoded instead of the Git Parameter variable, checkouts work fine even in kubernetes environment

          1) SCM configuration

          !image-2023-08-11-17-50-31-412.png!

          2) Kubernetes agent/pod is created and checkout is performed inside, branch name is now correct (highlighted) [{_}Stage =>{_} {_}Build PHP test image{_}]

          !image-2023-08-11-18-01-25-547.png!
           * Why is the Git Parameter variable not recognized by kubernetes?
           * How can we pass that variable to kubernete-pligin?

          Could you help on this? Thanks in advance

          Regards!

           

           
          New: When using Git Parameter variable (ex ${BRANCH}) git checkout can be made in any "phisical node" but branch variable is not recognize by  any kubernetes agent, but if a string is used instead checkout is meade in kubernetes {{properly.}}

          *JOB CONFIG*

          1) Git Parameter configuration in job

          !image-2023-08-11-17-19-47-664.png!

          2) SCM configuration

          !image-2023-08-11-17-20-44-031.png!

          *FAILED PIPELINE LOGS*

          1) Correct SCM in 'master' label [\{_}Stage => Prepare\{_}], ${BRANCH} variable is highlighted

          !image-2023-08-11-17-28-13-417.png!

          (pipeline code block)

          !image-2023-08-11-17-31-36-824.png!

          Branch was clone fine

          2) When trying to clone inside kubernetes environment ${BRANCH} is not recognized [\{_}Stage =>\{_} \{_}Build PHP test image\{_}]. Variable is highlighted, values is not recognized (seems treated as string).

          !image-2023-08-11-17-37-56-019.png!

          (pipeline code block)

          *!image-2023-08-11-18-04-59-450.png!*

          *SUCCESS PIPELINE LOGS*

          If the needed branch is hardcoded instead of the Git Parameter variable, checkouts work fine even in kubernetes environment

          1) SCM configuration

          !image-2023-08-11-17-50-31-412.png!

          2) Kubernetes agent/pod is created and checkout is performed inside, branch name is now correct (highlighted) [\{_}Stage =>\{_} \{_}Build PHP test image\{_}]

          !image-2023-08-11-18-01-25-547.png!
           * Why is the Git Parameter variable not recognized by kubernetes?
           * How can we pass that variable to kubernete-pligin?

          Could you help on this? Thanks in advance

          Regards!

          PS: This is the kubernetes agent definition

          [^kaniko-pod-definition.yaml]

           
          David made changes -
          Description Original: When using Git Parameter variable (ex ${BRANCH}) git checkout can be made in any "phisical node" but branch variable is not recognize by  any kubernetes agent, but if a string is used instead checkout is meade in kubernetes {{properly.}}

          *JOB CONFIG*

          1) Git Parameter configuration in job

          !image-2023-08-11-17-19-47-664.png!

          2) SCM configuration

          !image-2023-08-11-17-20-44-031.png!

          *FAILED PIPELINE LOGS*

          1) Correct SCM in 'master' label [\{_}Stage => Prepare\{_}], ${BRANCH} variable is highlighted

          !image-2023-08-11-17-28-13-417.png!

          (pipeline code block)

          !image-2023-08-11-17-31-36-824.png!

          Branch was clone fine

          2) When trying to clone inside kubernetes environment ${BRANCH} is not recognized [\{_}Stage =>\{_} \{_}Build PHP test image\{_}]. Variable is highlighted, values is not recognized (seems treated as string).

          !image-2023-08-11-17-37-56-019.png!

          (pipeline code block)

          *!image-2023-08-11-18-04-59-450.png!*

          *SUCCESS PIPELINE LOGS*

          If the needed branch is hardcoded instead of the Git Parameter variable, checkouts work fine even in kubernetes environment

          1) SCM configuration

          !image-2023-08-11-17-50-31-412.png!

          2) Kubernetes agent/pod is created and checkout is performed inside, branch name is now correct (highlighted) [\{_}Stage =>\{_} \{_}Build PHP test image\{_}]

          !image-2023-08-11-18-01-25-547.png!
           * Why is the Git Parameter variable not recognized by kubernetes?
           * How can we pass that variable to kubernete-pligin?

          Could you help on this? Thanks in advance

          Regards!

          PS: This is the kubernetes agent definition

          [^kaniko-pod-definition.yaml]

           
          New: When using Git Parameter variable (ex ${BRANCH}) git checkout can be made in any "phisical node" but branch variable is not recognize by  any kubernetes agent, but if a string is used instead checkout is meade in kubernetes {{properly.}}

          *JOB CONFIG*

          1) Git Parameter configuration in job

          !image-2023-08-11-17-19-47-664.png!

          2) SCM configuration

          !image-2023-08-11-17-20-44-031.png!

          *FAILED PIPELINE LOGS*

          1) Correct SCM in 'master' label [\\{_}Stage => Prepare\\{_}], ${BRANCH} variable is highlighted

          !image-2023-08-11-17-28-13-417.png!

          (pipeline code block)

          !image-2023-08-11-17-31-36-824.png!

          Branch was clone fine

          2) When trying to clone inside kubernetes environment ${BRANCH} is not recognized [\\{_}Stage =>\\{_} \\{_}Build PHP test image\\{_}]. Variable is highlighted, values is not recognized (seems treated as string).

          !image-2023-08-11-17-37-56-019.png!

          (pipeline code block)

          *!image-2023-08-11-18-04-59-450.png!*

          *SUCCESS PIPELINE LOGS*

          If the needed branch is hardcoded instead of the Git Parameter variable, checkouts work fine even in kubernetes environment

          1) SCM configuration

          !image-2023-08-11-17-50-31-412.png!

          2) Kubernetes agent/pod is created and checkout is performed inside, branch name is now correct (highlighted) [\\{_}Stage =>\\{_} \\{_}Build PHP test image\\{_}]

          !image-2023-08-11-18-01-25-547.png!
           * Why is the Git Parameter variable not recognized by kubernetes?
           * How can we pass that variable to kubernete-pligin?

          Could you help on this? Thanks in advance

          Regards!

          PS: This is the kubernetes agent definition

          [^kaniko-pod-definition.yaml]

          *^(Also attahced)^*

           
          Mark Waite made changes -
          Comment [ Your experience highlights an intriguing issue. Being able to perform [templates|https://www.typecalendar.com/templates] Git checkout on any physical node using the Git Parameter variable, but not having the branch variable recognized by Kubernetes agents, suggests a complex problem. Especially, the variable behaving differently in various environments can be quite perplexing. ]
          David made changes -
          Attachment New: image-2023-08-15-13-16-26-101.png [ 61017 ]
          David made changes -
          Attachment New: image-2023-08-15-13-16-44-532.png [ 61018 ]
          Charles made changes -
          Comment [ I am having the same issue.  ]
          Charles made changes -
          Rank New: Ranked higher
          Mark Waite made changes -
          Comment [ Thanks for sharing this type of info. [HealthCareGov|https://www.health-insurancemarket.com] ]

            Unassigned Unassigned
            tang81 David
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: