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

git plugin sparse checkout path field does not expand variables

    • git client plugin 4.0.0

      I have carefully named my project paths and folders so I can use JOB_NAME substitutions when cloning templates to create new jobs. All I have to do is copy a similar test (selenium/jmeter/junit/etc) and set the name of the job.

      I just started using sparse checkout feature of git-client, to reduce the workspace bloat.

      I want to use variable substitution to checkout the path 'test/${JOB_NAME}'.

      The ${JOB_NAME} is not expanding, I get an error from the git-client, and the checkout fails. When I hardcode the jobname in the sparse checkout path field, it all works beautifully.

          [JENKINS-23477] git plugin sparse checkout path field does not expand variables

          Thomas Wabner added a comment -

          We see the same situation:

          we using some maven jobs and prepare the environment with some predefind variables like

          project_rel_path=maven/parents/web-parent

          Then we want to use in sparse-checkout path this variable like ${project_rel_path}. But we get then errors like
          *
          stderr: error: Sparse checkout leaves no entry on working directory*

          We need such "central" point of configuration for our project definitions, because if we sparse checkout such path, the path is checked out as it is. So the workspace contains a folder like

          /maven/parents/web-parent/

          As for a standard maven job, we need to define where to find the pom.xml ... in such way with sparse checkout, we need to configure, that the pom can be found under maven/parents/web-parent/pom.xml (and we cannot rely on default maven job behaviour, that the pom.xml is in root of workspace).

          One possible solution would be to provide a option to sparse checkout to root ... or to honor environment/build variables like ${xyz} and expand them.

          Environment:

          Windows 64, git client 2.7.0, jenkins 1.643, git plugin 2.4.1

          Thomas Wabner added a comment - We see the same situation: we using some maven jobs and prepare the environment with some predefind variables like project_rel_path=maven/parents/web-parent Then we want to use in sparse-checkout path this variable like ${project_rel_path} . But we get then errors like * stderr: error: Sparse checkout leaves no entry on working directory* We need such "central" point of configuration for our project definitions, because if we sparse checkout such path, the path is checked out as it is . So the workspace contains a folder like /maven/parents/web-parent/ As for a standard maven job, we need to define where to find the pom.xml ... in such way with sparse checkout, we need to configure, that the pom can be found under maven/parents/web-parent/pom.xml (and we cannot rely on default maven job behaviour, that the pom.xml is in root of workspace). One possible solution would be to provide a option to sparse checkout to root ... or to honor environment/build variables like ${xyz} and expand them. Environment: Windows 64, git client 2.7.0, jenkins 1.643, git plugin 2.4.1

          On the remote Jenkins workspace:

          $ cat .git/info/sparse-checkout 
          examples/
          hdl/platforms/${HDL_PLATFORM}
          

          Where HDL_PLATFORM is an axis in a matrix project.

          Aaron D. Marasco added a comment - On the remote Jenkins workspace: $ cat .git/info/sparse-checkout examples/ hdl/platforms/${HDL_PLATFORM} Where HDL_PLATFORM is an axis in a matrix project.

          same issue on Ubuntu 14.04, Jenkins 1.638, git plugin 2.3.4

          Peter Muryshkin added a comment - same issue on Ubuntu 14.04, Jenkins 1.638, git plugin 2.3.4

          Do we have any resolution for this ?
          We want to use variable in place of Sparse Checkout path

          Sagayaraj David added a comment - Do we have any resolution for this ? We want to use variable in place of Sparse Checkout path

          Monkey Little added a comment -

          We are having exactly the same issue right now and this is June 30, 2017.  We are on latest Jenkins version 2.60.1 and Git plugin version is 3.3.1.  

          As you can see, I'm using variables for repo URL,, branch spec, and sparse checkout path.  I've done some troubleshooting - if I put in the actual path for sparse checkout paths field, it works.  I also found .git/info/sparse-checkout file contains the unexpanded ${CUSTOM_PATH} as content.

          This bug should be fixed, I don't know why it's still not fixed?

           

          Monkey Little added a comment - We are having exactly the same issue right now and this is June 30, 2017.  We are on latest Jenkins version 2.60.1 and Git plugin version is 3.3.1.   As you can see, I'm using variables for repo URL,, branch spec, and sparse checkout path.  I've done some troubleshooting - if I put in the actual path for sparse checkout paths field, it works.  I also found .git/info/sparse-checkout file contains the unexpanded ${CUSTOM_PATH} as content. This bug should be fixed, I don't know why it's still not fixed?  

          Leo Brookes added a comment -

          +1 - being able to parameterise the checkout path would make life easier

          Leo Brookes added a comment - +1 - being able to parameterise the checkout path would make life easier

          Amruta Kale added a comment -

          +1 Is there any update on this? I am facing the exact same problem.

          Amruta Kale added a comment - +1 Is there any update on this? I am facing the exact same problem.

          jlpinardon added a comment - - edited

          I'd really like to be able to use variable with sparse checkout. It would be a great help in having more generic jobs and so on...
          Please, can we have some update on this ?
          I am not at all a java dev, and I don't want to be hurtful, but 6 years to find a fix seems to me a very long time ...

          jlpinardon added a comment - - edited I'd really like to be able to use variable with sparse checkout. It would be a great help in having more generic jobs and so on... Please, can we have some update on this ? I am not at all a java dev, and I don't want to be hurtful, but 6 years to find a fix seems to me a very long time ...

          Yan Kuang added a comment -

          +1 on this issue, would also like to have parameter for Sparse Checkout paths

          Yan Kuang added a comment - +1 on this issue, would also like to have parameter for Sparse Checkout paths

          Mark Waite added a comment -

          ytkme and jlpinardon you can parameterize sparse checkout paths if you use a Pipeline job to define the parameter type. That uses the capabilities of the Pipeline to perform the parameter replacement without requiring any change in the git plugin.

          Mark Waite added a comment - ytkme and jlpinardon you can parameterize sparse checkout paths if you use a Pipeline job to define the parameter type. That uses the capabilities of the Pipeline to perform the parameter replacement without requiring any change in the git plugin.

            yashj21 Yash Amrut Jain
            charlie_ecc Charlie Stott
            Votes:
            18 Vote for this issue
            Watchers:
            18 Start watching this issue

              Created:
              Updated:
              Resolved: