[JIRA] (JENKINS-62044) EXCLUDE patterns can't protect directories included by "**"

15 views
Skip to first unread message

andreas.ringlstetter@gmail.com (JIRA)

unread,
Apr 24, 2020, 5:57:02 AM4/24/20
to jenkinsc...@googlegroups.com
Andreas Ringlstetter created an issue
 
Jenkins / Bug JENKINS-62044
EXCLUDE patterns can't protect directories included by "**"
Issue Type: Bug Bug
Assignee: Oliver Gondža
Components: ws-cleanup-plugin
Created: 2020-04-24 09:56
Priority: Major Major
Reporter: Andreas Ringlstetter

Consider the following pipeline code:

void deleteOthers(List<String> pathList) {
	def prefixes = []
	for(path in pathList) {
		def currentPrefix = path;
		while(true) {
			def prefixEnd = currentPrefix.lastIndexOf("/")
			if(prefixEnd > 0) {
				currentPrefix = currentPrefix.substring(0, prefixEnd);
				prefixes.add(currentPrefix)
			} else {
				break;
			}
		}
	}
	prefixes.unique()
	
	def patterns = []
	for(path in prefixes) {
		patterns.add([
			pattern: '/' + path,
			type: 'EXCLUDE'
		])
	}
	for(path in pathList) {
		patterns.add([
			pattern: '/' + path,
			type: 'EXCLUDE'
		])
		patterns.add([
			pattern: '/' + path + '/**',
			type: 'EXCLUDE'
		])
	}
	patterns.add([
		pattern: '/**/*',
		type: 'INCLUDE'
	])
	
	
	cleanWs deleteDirs: true, patterns: patterns
	return
}

def keep = [
	'foo',
	'foo2',
	'bar/foo',
	'bar/foo2',
	'bar/foo3/bla'
]
writeFile file:'dummy', text:''   
for(path in keep) {
	dir(path) {
		writeFile file:'dummy', text:''   
	}
}
deleteOthers(keep)

Expected behavior:
All the listed directories listed in "keep" are preserved (as both the directories themselves, as well as all parents are explicitly excluded!) and the included files are preserved.

Only the file created outside the tree is expected to be removed.

Actual behavior:
Only the directories + paths "foo/dummy" and "foo2/dummy" are preserved.
All the directories with a nested paths, relative to include pattern, are impossible to preserve.

It appears as if excludes fail to apply to any directory, if the directory was matched using a non-empty "" part of the INCLUDE wildcard. Directories only matched by a single "" (or an empty "*") have their EXCLUDE rules evaluated correctly.

For files, excludes are properly evaluated even if the INCLUDE was matching with a non-empty "**".

E.g. with "deleteDirs: false", all expected files are protected correctly.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo

andreas.ringlstetter@gmail.com (JIRA)

unread,
Apr 24, 2020, 6:00:08 AM4/24/20
to jenkinsc...@googlegroups.com
Andreas Ringlstetter updated an issue
Consider the following pipeline code:
{code:java}
{code}
*Expected behavior:*

All the listed directories listed in "keep" are preserved (as both the directories themselves, as well as all parents are explicitly excluded!) and the included files are preserved.

Only the file created outside the tree is expected to be removed.

*Actual behavior:*

Only the directories + paths "foo/dummy" and "foo2/dummy" are preserved.
All the directories with a nested paths, relative to include pattern, are impossible to preserve.

It appears as if excludes fail to apply to any directory, if the directory was *matched using a non-empty " {code:java} ** " {code} part of the INCLUDE wildcard*. Directories only matched by a single " ` * " ` (or an empty "**") have their EXCLUDE rules evaluated correctly.


For files, excludes are properly evaluated even if the INCLUDE was matching with a non-empty "**".

E.g. with "deleteDirs: false", all expected files are protected correctly.

andreas.ringlstetter@gmail.com (JIRA)

unread,
Apr 24, 2020, 6:02:02 AM4/24/20
to jenkinsc...@googlegroups.com
It appears as if excludes fail to apply to any directory, if the directory was * matched using a non-empty {code:java}** {code} part of the INCLUDE wildcard * . Directories only matched by a single `*` ( star, or an empty "**") double-star have their EXCLUDE rules evaluated correctly.

For files, excludes are properly evaluated even if the INCLUDE was matching with a non-empty
"**" double-star .


E.g. with "deleteDirs: false", all expected files are protected correctly.

andreas.ringlstetter@gmail.com (JIRA)

unread,
Apr 24, 2020, 6:05:02 AM4/24/20
to jenkinsc...@googlegroups.com
for(path in keep) {
dir(path) {
  writeFile file:'
dummy expected ', text:''   
}
}
writeFile file:'unexpected', text:''
writeFile file:'bar/unexpected', text:''
deleteOthers(keep)
{code}
*Expected behavior:*
All the listed directories listed in "keep" are preserved (as both the directories themselves, as well as all parents are explicitly excluded!) and the included files are preserved.

Only the file files created outside the tree is of directories listed in "keep" are expected to be removed.


*Actual behavior:*
Only the directories + paths "foo/dummy" and "foo2/dummy" are preserved.
All the directories with a nested paths, relative to include pattern, are impossible to preserve.

It appears as if excludes fail to apply to any directory, if the directory was matched using a non-empty
{code:java}
**{code}
part of the INCLUDE wildcard. Directories only matched by a single star, or an empty double-star have their EXCLUDE rules evaluated correctly.

For files, excludes are properly evaluated even if the INCLUDE was matching with a non-empty double-star.


E.g. with "deleteDirs: false", all expected files are protected correctly.

andreas.ringlstetter@gmail.com (JIRA)

unread,
Apr 24, 2020, 6:06:02 AM4/24/20
to jenkinsc...@googlegroups.com
for(path in keep) {
dir(path) {
  writeFile file:'expected', text:''   

}
}
writeFile file:'unexpected', text:''
writeFile file:'bar/unexpected', text:''
deleteOthers(keep)
{code}
*Expected behavior:*
All the listed directories listed in "keep" are preserved (as both the directories themselves, as well as all parents are explicitly excluded!) and the included files are preserved.

Only the files created outside of directories listed in "keep" are expected to be removed.

*Actual behavior:*
Only the directories + paths "foo/
dummy expected " and "foo2/ dummy expected " are preserved.

All the directories with a nested paths, relative to include pattern, are impossible to preserve.

It appears as if excludes fail to apply to any directory, if the directory was matched using a non-empty
{code:java}
**{code}
part of the INCLUDE wildcard. Directories only matched by a single star, or an empty double-star have their EXCLUDE rules evaluated correctly.

For files, excludes are properly evaluated even if the INCLUDE was matching with a non-empty double-star.

E.g. with "deleteDirs: false", all expected files are protected correctly.

andreas.ringlstetter@gmail.com (JIRA)

unread,
Apr 24, 2020, 6:07:02 AM4/24/20
to jenkinsc...@googlegroups.com
writeFile file:'bar/foo3/unexpected', text:''
deleteOthers(keep)
{code}
*Expected behavior:*
All the listed directories listed in "keep" are preserved (as both the directories themselves, as well as all parents are explicitly excluded!) and the included files are preserved.

Only the files created outside of directories listed in "keep" are expected to be removed.

*Actual behavior:*
Only the directories + paths "foo/expected" and "foo2/expected" are preserved.

All the directories with a nested paths, relative to include pattern, are impossible to preserve.

It appears as if excludes fail to apply to any directory, if the directory was matched using a non-empty
{code:java}
**{code}
part of the INCLUDE wildcard. Directories only matched by a single star, or an empty double-star have their EXCLUDE rules evaluated correctly.

For files, excludes are properly evaluated even if the INCLUDE was matching with a non-empty double-star.

E.g. with "deleteDirs: false", all expected files are protected correctly.
Reply all
Reply to author
Forward
0 new messages