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

Allow disabling use of default exclude patterns (.git, .svn, etc.) for archiving

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • core
    • Any

      The plugin available to archive artifacts doesn't allow to chose to archive hidden files/directories like .git, .svn, etc. This feature will help Continuous Integration teams to upstream the .git information to be used for example to get last commit hash, repository server, etc.
      Today, the plugin that copy the workspace is not useful when you do not need more than that artifacts, ans, in some cases, the repository is big.
      Maybe, the plugin can be changed to allow the copy, by selecting the file types.
      I am talking about to change the plugin "Archive Artifact" and "Copy Artifact".

          [JENKINS-20086] Allow disabling use of default exclude patterns (.git, .svn, etc.) for archiving

          Eduardo Dias created issue -

          mbaker000 added a comment -

          While it's a fair amount of hackery you can do this to work around this limitation:

          1. use 7-Zip to package up your workspace
          2. archive the zip file as an artifact
          3. copy the zip file as an artifact to your next pipeline build
          4. unzip the zip file
          5. do your normal build steps

          mbaker000 added a comment - While it's a fair amount of hackery you can do this to work around this limitation: 1. use 7-Zip to package up your workspace 2. archive the zip file as an artifact 3. copy the zip file as an artifact to your next pipeline build 4. unzip the zip file 5. do your normal build steps

          mike omoto added a comment -

          You can also emulate this behavior by using the post-build task plugin with the following setup:

          Log Text: Archiving artifacts

          cp -r .git ../builds/$BUILD_NUMBER/archive/.git/
          cp .gitignore ../builds/$BUILD_NUMBER/archive/.gitignore
          cp .gitattributes ../builds/$BUILD_NUMBER/archive/.gitattributes

          mike omoto added a comment - You can also emulate this behavior by using the post-build task plugin with the following setup: Log Text: Archiving artifacts cp -r .git ../builds/$BUILD_NUMBER/archive/.git/ cp .gitignore ../builds/$BUILD_NUMBER/archive/.gitignore cp .gitattributes ../builds/$BUILD_NUMBER/archive/.gitattributes

          Gigi Lentini added a comment -

          I came across the same issue using Jenkins 1.554.1, and the zip/unzip workaround seems to work for the moment.
          But I would rather use a clear jenkins config to do so.

          Do you have any update?

          Thanks.

          Gigi Lentini added a comment - I came across the same issue using Jenkins 1.554.1, and the zip/unzip workaround seems to work for the moment. But I would rather use a clear jenkins config to do so. Do you have any update? Thanks.

          Daniel Beck added a comment -

          Jenkins uses Ant to archive files. It excludes the following patterns related to various SCM by default (run in Script Console):

          org.apache.tools.ant.DirectoryScanner.defaultExcludes.each { println it }

          This can be changed globally by running the script below in the Script Console (until the next restart) or by adding a .groovy file with that script in JENKINS_HOME/init.groovy.d/ so this gets loaded upon startup:

          org.apache.tools.ant.DirectoryScanner.defaultExcludes.each { org.apache.tools.ant.DirectoryScanner.removeDefaultExclude(it) }

          I doubt that this is deserving a per-project preference, given the relative obscurity of the requirement. IMO a cleaner solution would be to extract the relevant data during the build and store it outside the SCM metadata folders.

          Daniel Beck added a comment - Jenkins uses Ant to archive files. It excludes the following patterns related to various SCM by default (run in Script Console): org.apache.tools.ant.DirectoryScanner.defaultExcludes.each { println it } This can be changed globally by running the script below in the Script Console (until the next restart) or by adding a .groovy file with that script in JENKINS_HOME/init.groovy.d/ so this gets loaded upon startup: org.apache.tools.ant.DirectoryScanner.defaultExcludes.each { org.apache.tools.ant.DirectoryScanner.removeDefaultExclude(it) } I doubt that this is deserving a per-project preference, given the relative obscurity of the requirement. IMO a cleaner solution would be to extract the relevant data during the build and store it outside the SCM metadata folders.

          relative obscurity of the requirement

          why is it obscurs?

          I have the same issue. First step clean/install the maven project on a private maven repo (to avoid snapshot deps collision between a reentrant pipeline) and archive the workspace. Next steps (test, sonar, deploy on nexus, deploy on tomcat...) reuse this archive instead of rebuilding the project. Sonar steps need the .svn which are not copied by the archive plugin.

          Is this pipeline wrong?

          Nicolas Labrot added a comment - relative obscurity of the requirement why is it obscurs? I have the same issue. First step clean/install the maven project on a private maven repo (to avoid snapshot deps collision between a reentrant pipeline) and archive the workspace. Next steps (test, sonar, deploy on nexus, deploy on tomcat...) reuse this archive instead of rebuilding the project. Sonar steps need the .svn which are not copied by the archive plugin. Is this pipeline wrong?

          Daniel Beck added a comment -

          It's not something that can be done out of the box, you need e.g. Copy Artifacts plugin for that.

          Still, it does seem like a somewhat surprising behavior – it's only unsurprising if you know it uses Ant, and that's a build tool. I'm not sure what the best way to introduce an option is though – just clearing the default excludes can well be considered a regression. Per-instance option is too heavy-handed. Per-job option seems to be the only sensible one left. Given the apparent reluctance of others to merge my 'archive only if successful' option in 1.567, I'm not looking forward to an argument about this

          I'm adding this to my list of things I'd like to fix, but anyone feel free to take over.

          Daniel Beck added a comment - It's not something that can be done out of the box, you need e.g. Copy Artifacts plugin for that. Still, it does seem like a somewhat surprising behavior – it's only unsurprising if you know it uses Ant, and that's a build tool. I'm not sure what the best way to introduce an option is though – just clearing the default excludes can well be considered a regression. Per-instance option is too heavy-handed. Per-job option seems to be the only sensible one left. Given the apparent reluctance of others to merge my 'archive only if successful' option in 1.567, I'm not looking forward to an argument about this I'm adding this to my list of things I'd like to fix, but anyone feel free to take over.
          Daniel Beck made changes -
          Assignee New: Daniel Beck [ danielbeck ]
          Daniel Beck made changes -
          Component/s New: core [ 15593 ]
          Component/s Original: plugin [ 15491 ]
          Labels Original: archiving artifact plugin New: archiving artifact
          Daniel Beck made changes -
          Fix Version/s Original: current [ 10162 ]
          Affects Version/s Original: current [ 10162 ]
          Due Date Original: 2013-10-31
          Environment Original: Jenkins 1.509.4 LTS
          Ubuntu 12.04 LTS
          New: Any
          Summary Original: Improve the archive artifacts plugin to incude hidden files/directories like .git New: Allow disabling use of default exclude patterns (.git, .svn, etc.)

            nithril Nicolas Labrot
            eduardodias Eduardo Dias
            Votes:
            1 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: