-
-
Notifications
You must be signed in to change notification settings - Fork 122
[JENKINS-22637] ArtifactManager support #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ikedam
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
you should create a tarball and archive that instead
+1
Users are recommended to use zip, unzip steps or call tar command via sh step.
Unfortunately, zip step doesn't support exclude filters...
| * @deprecated No longer used. | ||
| */ | ||
| @Deprecated | ||
| public abstract class Copier implements ExtensionPoint { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove them.
It's useless to preserving binary compatibilities as they're completely no longer used,
and exceptions should occur if someone use them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, no “exception” would result from using them somehow. I do not have a strong opinion either way.
| throw new AbortException(message); | ||
| } | ||
| } | ||
| FilePath targetDir = workspace, baseTargetDir = targetDir; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for me: baseTargerDir looks not used at all. Completely useless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, AFAICT it was never used anyway.
|
@ikedam so I am leaving it up to your judgment what to do here. I noted the number of JIRA votes for various affected issues, to the extent that is meaningful data. This PR in isolation implements a feature with 14 votes (and no good workaround), and regresses three bug reports with a combined total of 14 votes (and the workaround of archiving a tarball rather than individual files). #100 implements the feature (and more) without regressing any of the prior bugs, but will require a new core baseline. 🤷♂️ One option not previously discussed would be to merge this but release only as a The hope is that once JEP-301 is deployed, Essentials users would get new stuff that just works, right away. Obviously a lot needs to happen before that is a reality. |
oleg-nenashev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good in general. Some code could be moved to the core or API plugin if there are use-case in other plugins. 🐝
| for (FilePath file : list) | ||
| copier.copyOne(file, new FilePath(targetDir, file.getName()), isFingerprintArtifacts()); | ||
| cnt = list.length; | ||
| targetDir.mkdirs(); // Create target if needed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be nice to switch it to Java7 Files API while you are around
| try { | ||
| md5 = MessageDigest.getInstance("MD5"); | ||
| } catch (NoSuchAlgorithmException x) { | ||
| throw new AssertionError(x); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does not really matter, but maybe just IOException? There were some discussions about disabling MD5 at all to harden the security. I'd guess it is not realistic, but I would rather prefer to avoid errors in the production code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To do that we would first need to reimplement fingerprints in Jenkins core, which would surely force changes here as well anyway.
| } | ||
| } | ||
|
|
||
| private static List<String> scan(VirtualFile root, String expandedFilter, @CheckForNull String expandedExcludes) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it should be moved to core utils eventually. Looks to be generic enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is deleted in #100.
| targetDir.mkdirs(); // Create target if needed | ||
| List<String> list = scan(srcDir, expandedFilter, expandedExcludes); | ||
| for (String file : list) { | ||
| copyOne(src, dst, fingerprints, srcDir.child(file), new FilePath(targetDir, isFlatten() ? file.replaceFirst(".+/", "") : file), md5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
passing isFingerprintArtifacts() looked better, but OK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But now we need to pass in the map.
| copier.end(); | ||
| if (fingerprints != null) { | ||
| for (Run<?, ?> r : new Run<?, ?>[] {src, dst}) { | ||
| if (fingerprints.size() > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not modified inside the cycle IIUC, maybe makes sense to just move to the outer check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does not really matter—the loop has only two iterations.
| return pattern; | ||
| } | ||
|
|
||
| private static void copyOne(Run<?,?> src, Run<?,?> dst, Map<String, String> fingerprints, VirtualFile s, FilePath d, MessageDigest md5) throws IOException, InterruptedException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same, does not seem to be plugin-specific
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is pretty specific to copyartifact I think.
| targetDir.mkdirs(); // Create target if needed | ||
| List<String> list = scan(srcDir, expandedFilter, expandedExcludes); | ||
| for (String file : list) { | ||
| copyOne(src, dst, fingerprints, srcDir.child(file), new FilePath(targetDir, isFlatten() ? file.replaceFirst(".+/", "") : file), md5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for me: snipping ".+/" is equivalent to the current implementation calling FilePath#getName() in FingerprintingCopyMethod.
(I'm not sure this is a good behavior as reported in JENKINS-16987)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this replaceFirst call just implements the flatten mode. It has nothing to do with fingerprinting. The behavior you mention is retained in copyOne as
fingerprints.put(s.getName(), digest);
// ^^^^^^^^^^There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I misplaced the comment!
https://github.com/jenkinsci/copyartifact-plugin/pull/100/files#r174750602
|
@jglick Sorry for my late response.
This option looks good to me. Let me have a little more time to work for https://issues.jenkins-ci.org/browse/JENKINS-47905 and https://issues.jenkins-ci.org/browse/JENKINS-47074.
|
|
As JENKINS-47074 will be resolved as Won't fix and JENKINS-47905 provides no new features, versions are: copyartifact-1.39.1: JENKINS-47905 |
|
Really sorry for long absence. |
|
Hmm... It seems that releasing 1.40 will mask 1.40-beta as described in https://jenkins.io/doc/developer/publishing/releasing-experimental-updates/. |
|
Released 1.40-beta-1 with this change. |
AFAIK not, since the UC for LTS users should only be offering 1.39. |
|
Updates center provides several versions of plugin lists for core versions by redirection.
But the experimental update center provides only one version, and will result 1.40-beta-1 inaccessible via the update center. Anyway, that doesn't matter so much as users can download the beta version directly from http://updates.jenkins-ci.org/download/plugins/copyartifact/1.40-beta-1/copyartifact.hpi . |
JENKINS-22637: supporting custom
ArtifactManagers viaVirtualFile. Unlike #71 the goal here is to make just this change with as little impact on existing installations as possible.compress-artifactsplugin (14 votes)To handle symlinks and file attributes may require new core APIs—TBD. Really if you care about platform-specific stuff like this you should create a tarball and archive that instead, since you cannot guarantee that the Jenkins master will preserve these nuances. Similarly, suppressing of default excludes is desirable but might just be treated as a core bug fix, and again it is going to be safer and much more efficient to create a ZIP or tarball of all your little files.
I also plan to
but this will certainly require a new core baseline and might better be filed as an add-on PR.
Note that I am dropping the
Copierextension point here. In practice I doubt this would be incompatible for anyone:There are no known external implementations.
This never really behaved like a regular extension point to begin with: the user cannot select an implementation! In fact
FilePathCopyMethodwas dead code—even as of 3cf80e5, it was always overridden byFingerprintingCopyMethod. And that one was rather misnamed as of JENKINS-12134 - Make fingerprinting artifacts optional. #11—it may or may not do fingerprinting!JENKINS-7753 claimed as justification
which is sensible enough but better handled via
ArtifactManager, especially as of JENKINS-49635.I am also making an API change to
BuildSelector. In this case there are two known external implementations but neither override thegetSourceDirectorymethod. In fact, other thanWorkspaceSelector, it is hard to imagine any other useful override. I am making a cursory effort to retain compatibility with any external overrides just in case.Subsumes #98.
@reviewbybees