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

Add another '-f' to git clean to remove deleted submodules or other repos checked out in workspace in pipeline

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Component/s: git-client-plugin
    • Labels:
      None
    • Environment:
      Jenkins and multi SCM plugin configured with git repository using submodules
      Alternatively: A pipeline that checks out a second repository in a sub-dir
    • Similar Issues:

      Description

      Submodules clean up

      Jenkins SCM plugin can handle git repositories with submodules except for clean up.

      When "Clean before checkout" is selected, it runs 'git reset --hard && git clean -dxf' on the repository and submodules if "Recursively update submodules" is selected. This works for most stuff but it does not work if git submodule is removed from the tree which leaves the submodule directory in workspace even after 'git clean -dxf'.

      If another '-f' is added, also the removed submodule will be deleted which is the behavior I'd expect when git submodules are in use.

      So Jenkins git plugin should call 'git clean -dxf -f' in that case.

      Pipelines workspace reuse

      An alternative use case, which I believe is very common, is that a pipeline checks out a repository in a sub-directory. Since the workspaces are reused between builds, there is a big risk that code or generated files in that sub-directory from previous builds are still there in the next run. This can seriously impact reliability of build or even fail them. One case is that old cucumber test reports are found.

      Completely wiping the workspace has a performance cost that is unreasonable.

        Attachments

          Issue Links

            Activity

            Hide
            markewaite Mark Waite added a comment -

            One alternative is to use "Wipe workspace" either within the job definition (so that it happens at the start of each job).

            Another alternative might be to add a build step as a "pre-SCM" build step.

            Show
            markewaite Mark Waite added a comment - One alternative is to use "Wipe workspace" either within the job definition (so that it happens at the start of each job). Another alternative might be to add a build step as a "pre-SCM" build step.
            Hide
            lucasocio Leandro Lucarella added a comment -

            Any updates on this? The fix seems quite simple and it's a really annoying bug. Thanks!

            Show
            lucasocio Leandro Lucarella added a comment - Any updates on this? The fix seems quite simple and it's a really annoying bug. Thanks!
            Hide
            markewaite Mark Waite added a comment -

            I'd love to have help evaluating the two different pull requests which propose to add an optional additional "f" to the git clean command. Refer to

            • PR227
            • PR222 where you said it would fix it for you, but did not indicate that you've deployed it
            Show
            markewaite Mark Waite added a comment - I'd love to have help evaluating the two different pull requests which propose to add an optional additional "f" to the git clean command. Refer to PR227 PR222 where you said it would fix it for you, but did not indicate that you've deployed it
            Hide
            lucasocio Leandro Lucarella added a comment -

            Sorry, I forgot about the duplicated issue. Since this only bite us very seldom, and it takes some time to figure out what the problem was, is hard to remember all the details about the issue.

            Is there any way to get an easily installable plugin that contains the fix to test it? Thanks!

            Show
            lucasocio Leandro Lucarella added a comment - Sorry, I forgot about the duplicated issue. Since this only bite us very seldom, and it takes some time to figure out what the problem was, is hard to remember all the details about the issue. Is there any way to get an easily installable plugin that contains the fix to test it? Thanks!
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Samantha Schwarz
            Path:
            src/main/java/hudson/plugins/git/GitAPI.java
            src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java
            src/main/java/org/jenkinsci/plugins/gitclient/GitClient.java
            src/main/java/org/jenkinsci/plugins/gitclient/JGitAPIImpl.java
            src/main/java/org/jenkinsci/plugins/gitclient/RemoteGitImpl.java
            src/test/java/org/jenkinsci/plugins/gitclient/GitAPITestCase.java
            http://jenkins-ci.org/commit/git-client-plugin/58a322534f70180f5cba17e8f09c0e40df7fd962
            Log:
            Clean takes a flag that will add a --force flag to clean.

            See bug report https://issues.jenkins-ci.org/browse/JENKINS-26660 for more details

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Samantha Schwarz Path: src/main/java/hudson/plugins/git/GitAPI.java src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java src/main/java/org/jenkinsci/plugins/gitclient/GitClient.java src/main/java/org/jenkinsci/plugins/gitclient/JGitAPIImpl.java src/main/java/org/jenkinsci/plugins/gitclient/RemoteGitImpl.java src/test/java/org/jenkinsci/plugins/gitclient/GitAPITestCase.java http://jenkins-ci.org/commit/git-client-plugin/58a322534f70180f5cba17e8f09c0e40df7fd962 Log: Clean takes a flag that will add a --force flag to clean. See bug report https://issues.jenkins-ci.org/browse/JENKINS-26660 for more details

              People

              • Assignee:
                Unassigned
                Reporter:
                mcfrisk Mikko Rapeli
              • Votes:
                21 Vote for this issue
                Watchers:
                29 Start watching this issue

                Dates

                • Created:
                  Updated: