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

Lightweight checkout breaks variable expansion for GIT branch

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • branch-api-plugin
    • None
    • Windows 10
      Jenkins 2.277.1
      jenkinsfile

      (As always, I have no idea what component to select. Why do you ask an lay person like me to pick a component? Only a Jenkins developer knows what components there are and how to assign to one.)

      The issue I'm having is the same (or very similar) to JENKINS-42971 and JENKINS-28447. Both are marked resolved. But happens for me and I'm using latest version of Jenkins.

      As described in 42971 I have param named GIT_BRANCH and for the git repo setup I have the branch set to ${GIT_BRANCH}. Without lightweight checkout, this works as I want; the branch specified by the parameter value is checked out. But, with lightweight checkout selected, it tries to checkout branch "${GIT_BRANCH}" which is not what I want nor does it exist.

       

          [JENKINS-65299] Lightweight checkout breaks variable expansion for GIT branch

          Stephane Odul added a comment -

          We are having the same issue and this causing underlying other problems because we have many pipelines against a mono repo and the workspace directory on the controller has become massive while we only need the jenkinsfile.

          We have a custom shell wrapper to address other issues with the Git plugin and we did try to expand ${GIT_BRANCH} but that is not available in the environment variables so this cannot be fixed without fixing either the plugin that managed the Lightweight Checkout checkbox or the Git  plugin. At scale this is causing a significant amount of useless CPU, RAM and io load.

          markewaite I see that there are several similar issues with the environment variables not being expanded properly. Is this something that is likely to be fixed in the short term?

          Stephane Odul added a comment - We are having the same issue and this causing underlying other problems because we have many pipelines against a mono repo and the workspace directory on the controller has become massive while we only need the jenkinsfile. We have a custom shell wrapper to address other issues with the Git plugin and we did try to expand ${GIT_BRANCH} but that is not available in the environment variables so this cannot be fixed without fixing either the plugin that managed the Lightweight Checkout checkbox or the Git  plugin. At scale this is causing a significant amount of useless CPU, RAM and io load. markewaite  I see that there are several similar issues with the environment variables not being expanded properly. Is this something that is likely to be fixed in the short term?

          Mark Waite added a comment -

          markewaite I see that there are several similar issues with the environment variables not being expanded properly. Is this something that is likely to be fixed in the short term?

          Not likely to be fixed in the short term. The fix that was applied in an earlier case of lightweight checkout required changes across multiple plugins and a very determined contributor that guided it through to completion. I'm not actively working on this issue and don't plan to work on it in the near future.

          Mark Waite added a comment - markewaite  I see that there are several similar issues with the environment variables not being expanded properly. Is this something that is likely to be fixed in the short term? Not likely to be fixed in the short term. The fix that was applied in an earlier case of lightweight checkout required changes across multiple plugins and a very determined contributor that guided it through to completion. I'm not actively working on this issue and don't plan to work on it in the near future.

          Stephane Odul added a comment -

          Thanks for the update. Something we will try is expand our shell wrapper for the git commands on the controller to detect that is on our monorepo and if so to only expand the jenkinsfiles. This would probably reduce the size of the workspaces directory on the controller by over 95% in our case. That would be a hack but should work well.

          Stephane Odul added a comment - Thanks for the update. Something we will try is expand our shell wrapper for the git commands on the controller to detect that is on our monorepo and if so to only expand the jenkinsfiles. This would probably reduce the size of the workspaces directory on the controller by over 95% in our case. That would be a hack but should work well.

            Unassigned Unassigned
            sbroshar steve
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: