-
Improvement
-
Resolution: Fixed
-
Minor
-
None
-
Powered by SuggestiMate
It would be nice to have option to search artifacts by pattern in case insensitive way.
- CaseInsensitive.png
- 38 kB
- CaseSensitive.png
- 19 kB
- is duplicated by
-
JENKINS-30721 Filesets on Windows shall be case insensitive
-
- Closed
-
- is related to
-
JENKINS-30721 Filesets on Windows shall be case insensitive
-
- Closed
-
[JENKINS-5253] artifacts archiving: add option for treating patterns in case insensitive way
dominiquebrice: This is about artifact archiving, a post-build step. You specify an Ant-style pattern like
**/*.hpi
and apparently that's case sensitive and no way to make it case insensitive.
I propose to add a checkbox in the "Advanced..." section of the Artifacts Archiving settings, to indicate whether include and exclude patterns should be considered as case sensitive (default, same behavior as today) or case insensitive (new behavior).
It's consistent with existing UI, so makes sense.
A few more options and an approach like Git plugin's additional behaviors would make more sense, but that's still off a bit IMO.
Could the suggestion in the second screen shot be improved to suggest the lowercase file name variant? Or too much effort for too little gain?
I think it would be a bit complicated to reconstruct the right pattern with the right case, combining the pattern entered by the user and the files actually found by the DirectoryScanner with case insensitivity.
An easier (at least it seems easy when I look at the code, haven't tested yet ) and probably as helpful approach would be a message along the way of "*/.HPI doesn't match anything with case sensitivity, but it does with case insensitivity".
Some comments about case sensitivity behavior: this feature is based entirely on the behavior of case (in)sensitivity of the org.apache.ant:ant:1.8.3 dependency. In particular AbstractFileSet.setCaseSensitive() and DirectoryScanner.setCaseSensitive() (I was able to find online only the 1.6.1 javadoc but I didn't see any difference with the javadoc of the actual 1.8.3 code). There's not much in the javadoc regarding this flag besides a comment in DirectoryScanner : "Case sensitivity may be turned off if necessary. By default, it is turned on. ".
Looking at the code it seems that the library ignore the case-sensitivity of the underlying OS. It does its own processing and does not delegate the matching to the OS. The only thing that comes from the OS are the filenames, and the comparisons are made in Java using String.equals() (see for instance code of private method DirectoryScanner.isIncluded()).
My testing procedure:
- on-the-fly validation in job settings
- create a new job, keep default settings in Artifacts Archiving, enter a valid path: no warning display
- change some of the valid pattern to opposite case, get a warning message
- uncheck the "Treat include and exclude patterns as case sensitive" checkbox, warning goes away
- put the pattern to the correct case again, still no warning
- actual archiving at build time
- configure a job with a 'matching' pattern but with incorrect case, uncheck the "case sensitive" option -> artifacts are correctly archived at build time
- configure a job with a 'matching' pattern but with incorrect case, check the "case sensitive" option -> artifacts are NOT archived at build time
- configure a job with a matching pattern and correct case, check the "case sensitive" option -> artifacts are correctly archived at build time
- configure a job with a matching pattern and correct case, uncheck the "case sensitive" option -> artifacts are correctly archived at build time
- configure a job with a not matching pattern, uncheck the "case sensitive" option -> nothing is archived at build time
My results:
- MacOS X (10.9.5, java 1.7.0-45): OK
- Windows (Windows 7, java 1.7.0-51): OK
- Linux: I don't have one
Daniel, see new attached screenshot CaseSensitiveMessage.png. It's fairly easy in FilePath.validateAntFileMask() to verify this situation and provide specific feedback to the user.
There are four others such scenarios that are checked in the code (see lines 2248-2328 in original source code). I added this new check as the first one if there is no match with the exact criteria provided to the users. I'm open to suggestions on whether the case-sensitive/insensitive alternative check should be moved down in this list of checks.
Code changed in jenkins
User: Dominique
Path:
core/src/main/java/hudson/FilePath.java
core/src/main/java/hudson/tasks/ArtifactArchiver.java
core/src/main/java/hudson/util/FormFieldValidator.java
core/src/main/resources/hudson/Messages.properties
core/src/main/resources/hudson/tasks/ArtifactArchiver/config.jelly
core/src/main/resources/hudson/tasks/ArtifactArchiver/config.properties
core/src/main/resources/hudson/tasks/ArtifactArchiver/help-caseSensitive.html
core/src/test/java/hudson/FilePathTest.java
http://jenkins-ci.org/commit/jenkins/40382c5fc443f1cf1510103d80ec8358bb2f19d1
Log:
JENKINS-5253 Allow case insensitive patterns in Artifacts Archiving
Code changed in jenkins
User: Oleg Nenashev
Path:
core/src/main/java/hudson/FilePath.java
core/src/main/java/hudson/tasks/ArtifactArchiver.java
core/src/main/java/hudson/util/FormFieldValidator.java
core/src/main/resources/hudson/Messages.properties
core/src/main/resources/hudson/tasks/ArtifactArchiver/config.jelly
core/src/main/resources/hudson/tasks/ArtifactArchiver/config.properties
core/src/main/resources/hudson/tasks/ArtifactArchiver/help-caseSensitive.html
core/src/test/java/hudson/FilePathTest.java
http://jenkins-ci.org/commit/jenkins/4fd10ed7236cf7322a84f5c8221b5870baab694c
Log:
Merge pull request #1429 from dominiquebrice/jenkins-5253b
JENKINS-5253 Allow case insensitive patterns in Artifacts Archiving
Compare: https://github.com/jenkinsci/jenkins/compare/c3a68975584d...4fd10ed7236c
Code changed in jenkins
User: Oleg Nenashev
Path:
changelog.html
core/src/test/java/hudson/FilePathTest.java
http://jenkins-ci.org/commit/jenkins/858849ef42ab2e1da66e1017ca1b6c86fa92c080
Log:
Noting JENKINS-5253 from https://github.com/jenkinsci/jenkins/pull/1429
Integrated in jenkins_main_trunk #4329
JENKINS-5253 Allow case insensitive patterns in Artifacts Archiving (Revision 40382c5fc443f1cf1510103d80ec8358bb2f19d1)
Noting JENKINS-5253 from https://github.com/jenkinsci/jenkins/pull/1429 (Revision 858849ef42ab2e1da66e1017ca1b6c86fa92c080)
Result = SUCCESS
dominiquebrice : 40382c5fc443f1cf1510103d80ec8358bb2f19d1
Files :
- core/src/test/java/hudson/FilePathTest.java
- core/src/main/java/hudson/util/FormFieldValidator.java
- core/src/main/resources/hudson/tasks/ArtifactArchiver/config.properties
- core/src/main/java/hudson/FilePath.java
- core/src/main/resources/hudson/tasks/ArtifactArchiver/config.jelly
- core/src/main/resources/hudson/Messages.properties
- core/src/main/resources/hudson/tasks/ArtifactArchiver/help-caseSensitive.html
- core/src/main/java/hudson/tasks/ArtifactArchiver.java
o.v.nenashev : 858849ef42ab2e1da66e1017ca1b6c86fa92c080
Files :
- core/src/test/java/hudson/FilePathTest.java
- changelog.html
Fix was merged in master branch and is available in Jenkins 1.634 onwards.
Could someone provide a detailed scenario to understand the requirement? Which search on which page should provide insensitive search? thx