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

Git Client plugin's CLI implementation does not interoperate with Kubernetes plugin

XMLWordPrintable

      When `checkout` or `git` steps run inside the Kubernetes plugin's `container` block the Git CLI is expected to be executed on the specified container but it is not. It is executed in the jnlp container disregarding the `container` step.

      Below is a test Pipeline. It relies on the custom docker image (duemir/jenkins-jnlp-agent:alpine-no-git) which is based on the `jenkins/jnlp-slave:alpine` Dockerfile but with `git` installation removed. The Console Output is attached. 

      Env:

      Jenkins 2.138.4

      Git plugin 3.9.1 

      Git Client plugin 2.7.3 

      Kuberentes plugin 1.12.8 

      pipeline {
        agent {
          kubernetes {
            cloud 'kubernetes'
            label 'custom-jnlp-without-git'
            yaml """
      kind: Pod
      apiVersion: v1
      spec:
        containers:
        - name: jnlp
          image: duemir/jenkins-jnlp-agent:alpine-no-git
          imagePullPolicy: Always
          args: ['\$(JENKINS_SECRET)', '\$(JENKINS_NAME)']
        - name: worker
          image: jenkins/slave:latest
          imagePullPolicy: Always
          tty: true
          command:
          - /bin/sh
          args:
          - -c
          - cat
      """
          }
        }
        stages {
          stage('Run') {
            steps {
              sh '''
              echo This runs on jnlp container
              git --version || true
              '''
             container('worker') {
                sh '''
                echo This runs on jnlp-slave container
                git --version || true
                '''
                // This doesn't run on `jnlp-slave` container, it runs on the jnlp container
                git 'https://github.com/jglick/simple-maven-project-with-tests.git'
              }
            }
          }
        }
      }
       

       

            Unassigned Unassigned
            duemir Denys Digtiar
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: