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

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

      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'
              }
            }
          }
        }
      }
       

       

          [JENKINS-56076] Git Client plugin's CLI implementation does not interoperate with Kubernetes plugin

          Mark Waite added a comment -

          Possibly related to the pull request from ndeloof to fix the execution location or remoting location of portions of the git plugin or git client plugin?

          I don't plan to work on this anytime soon since my focus is on the BuildData bloat fix and the JGit improvements in git plugin 4.0.0 and git client 3.0.0. Pull requests will be happily considered with tests to duplicate the problem and an implementation to fix the tests and solve the bug.

          Mark Waite added a comment - Possibly related to the pull request from ndeloof to fix the execution location or remoting location of portions of the git plugin or git client plugin? I don't plan to work on this anytime soon since my focus is on the BuildData bloat fix and the JGit improvements in git plugin 4.0.0 and git client 3.0.0. Pull requests will be happily considered with tests to duplicate the problem and an implementation to fix the tests and solve the bug.

          issue known for a long time (already reported on docker-slaves-plugin)

          see https://github.com/jenkinsci/git-client-plugin/pull/219

           

           

          Nicolas De Loof added a comment - issue known for a long time (already reported on docker-slaves-plugin) see https://github.com/jenkinsci/git-client-plugin/pull/219    

          Jesse Glick added a comment -

          Well-known limitation.

          Jesse Glick added a comment - Well-known limitation.

          Torsten Reinhard added a comment - - edited

          Hi jglick, what is the suggested workaround / solution to that in a Kubernetes / openshift POD?
          Not being able to use checkout scm with ssh:// based URLs is a very hard limitation, since most pipelines are starting with checking out some code.
          Doing it manually with a

          sh "git clone ssh://path/to/repo.git" 

          also doesnt work out-of-the-box due to HostKeyVerification failure (beside others)

          Torsten Reinhard added a comment - - edited Hi jglick , what is the suggested workaround / solution to that in a Kubernetes / openshift POD? Not being able to use checkout scm with ssh:// based URLs is a very hard limitation, since most pipelines are starting with checking out some code. Doing it manually with a sh "git clone ssh: //path/to/repo.git" also doesnt work out-of-the-box due to HostKeyVerification failure (beside others)

          Jesse Glick added a comment -

          checkout scm should work at top level in node. Just be aware that running it inside a container step will still in fact use the default (jnlp) container. So, if using CLI Git, that container must have a git executable. Which typical images already will.

          Jesse Glick added a comment - checkout scm should work at top level in node . Just be aware that running it inside a container step will still in fact use the default ( jnlp ) container. So, if using CLI Git, that container must have a git executable. Which typical images already will.

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

              Created:
              Updated:
              Resolved: