• Icon: Improvement Improvement
    • Resolution: Won't Do
    • Icon: Minor Minor
    • git-plugin
    • None

      I would like to suggest an option to allow exclusions for git clean. Currently, when "Clean workspace" is selected, "git clean -fdx" is run, which is a great way of starting with a pristine build directory. However, if for Maven projects a "Local to the workspace" M2 repository is selected, the clean command will also clean away the repository, which will cause hundreds of artifacts to be re-downloaded. Even though a maven proxy makes this les worse, it would be nice if there was an option to allow exclusions from the clean (git clean -fdx -e <pattern>).

          [JENKINS-29893] Allow exclusions for git clean

          Mark Waite added a comment -

          If we implement exclusions for clean, we should also include implementing timeout for clean, since it would change the same part of the user interface.

          Mark Waite added a comment - If we implement exclusions for clean, we should also include implementing timeout for clean, since it would change the same part of the user interface.

          Peter McEvoy added a comment -

          Would be nice if a boolean could be passed in to conditionally control if clean should happen or not.  For fast incremental builds I don't want to clean, but occasionally I need to remove rogue binaries hanging around the workspace and I'd like a to let a build parameter control that

          Peter McEvoy added a comment - Would be nice if a boolean could be passed in to conditionally control if clean should happen or not.  For fast incremental builds I don't want to clean, but occasionally I need to remove rogue binaries hanging around the workspace and I'd like a to let a build parameter control that

          Any news? I would like to see "Clean before checkout" behaviour to have an option to add an exclude pattern:

           

          https://git-scm.com/docs/git-clean

           

          Now I'm executing the command myself without using this behaviour as it does not support it. Example: 'git clean -fdx -e MyFolderToExclude'

          Borja Domínguez added a comment - Any news? I would like to see "Clean before checkout" behaviour to have an option to add an exclude pattern:   https://git-scm.com/docs/git-clean   Now I'm executing the command myself without using this behaviour as it does not support it. Example: 'git clean -fdx -e MyFolderToExclude'

          Mark Waite added a comment - - edited

          I have no plans currently to implement this in the plugin. It is simple to call the git clean command from Jenkins Pipeline and is not much more difficult to call it from Freestyle jobs.

          The git clean command does not require authentication, so does not need the added logic that the git plugin provides for authentication support.

          Mark Waite added a comment - - edited I have no plans currently to implement this in the plugin. It is simple to call the git clean command from Jenkins Pipeline and is not much more difficult to call it from Freestyle jobs. The git clean command does not require authentication, so does not need the added logic that the git plugin provides for authentication support.

          I know that. It's what I'm currently doing.

          But it would be nice that we could do it in "Clean before checkout" behaviour on Jenkins UI because everywhere where we are calling "checkout scm" uses that configuration. In this case I need to make two lines in my Jenkinsfile. 1-"git clean", 2-"checkout scm". In pipelines that you have stash and unstash you need to copy this code everywhere.

          Borja Domínguez added a comment - I know that. It's what I'm currently doing. But it would be nice that we could do it in "Clean before checkout" behaviour on Jenkins UI because everywhere where we are calling "checkout scm" uses that configuration. In this case I need to make two lines in my Jenkinsfile. 1-"git clean", 2-"checkout scm". In pipelines that you have stash and unstash you need to copy this code everywhere.

          Josiah Eubank added a comment -

          +1 for the script/pipeline maintenance of modifying everywhere that uses 'checkout scm'

          Josiah Eubank added a comment - +1 for the script/pipeline maintenance of modifying everywhere that uses 'checkout scm'

          Mark Waite added a comment -

          Closing this because I don't plan to implement it or to merge a pull request from someone else that implements it. If this level of control is needed, use Pipeline

          Mark Waite added a comment - Closing this because I don't plan to implement it or to merge a pull request from someone else that implements it. If this level of control is needed, use Pipeline

            Unassigned Unassigned
            sseidel sseidel
            Votes:
            6 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: