Skip to content

[JENKINS-63587] Allow disabling Ant default excludes in the zip step #180

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

Merged
merged 13 commits into from
Jan 16, 2023

Conversation

ykhandelwal913
Copy link

@ykhandelwal913 ykhandelwal913 commented Jan 9, 2023

Bydefault zipcreation excludes the default files like .gitignore and others mentioned in https://ant.apache.org/manual/dirtasks.html#defaultexcludes.

This PR is to solve https://issues.jenkins.io/browse/JENKINS-63587

Example:
zip zipFile: 'template.zip', archive: true, defaultExcludes:false, glob: 'template-*/**/*'
default value of defaultExcludes is true.

Copy link
Member

@rsandell rsandell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing documentation

@rsandell
Copy link
Member

rsandell commented Jan 9, 2023

@ykhandelwal913
Copy link
Author

@ykhandelwal913
Copy link
Author

Missing documentation

Done. Added in code itself. is that fine?

@rsandell
Copy link
Member

You also need to add a help-defaultExcludes.html to the resource directory https://github.com/jenkinsci/pipeline-utility-steps-plugin/tree/master/src/main/resources/org/jenkinsci/plugins/pipeline/utility/steps/zip/ZipStep with user documentation explaining what it is about, not every user can read java code :)

@ykhandelwal913
Copy link
Author

You also need to add a help-defaultExcludes.html to the resource directory https://github.com/jenkinsci/pipeline-utility-steps-plugin/tree/master/src/main/resources/org/jenkinsci/plugins/pipeline/utility/steps/zip/ZipStep with user documentation explaining what it is about, not every user can read java code :)

Done

@ykhandelwal913
Copy link
Author

@rsandell not sure why build is failing. Can you help?

@rsandell
Copy link
Member

Looks like an update of the build library causing javadoc generation to run and fail, not your fault.

@ykhandelwal913
Copy link
Author

ykhandelwal913 commented Jan 12, 2023

@rsandell If PR looking good, can that be merged?

@basil
Copy link
Member

basil commented Jan 13, 2023

Looks like the build failure is caused by a Javadoc error:

16:49:16  [ERROR] /home/jenkins/agent/workspace/line-utility-steps-plugin_PR-180/src/main/java/org/jenkinsci/plugins/pipeline/utility/steps/AbstractFileCompressStep.java:132: error: invalid use of @return
16:49:16  [ERROR]      * @return the defaultExcludes boolean
16:49:16  [ERROR]        ^

@basil
Copy link
Member

basil commented Jan 13, 2023

PS You can test Javadoc generation locally by running mvn clean verify -DskipTests -Pjenkins-release.

@ykhandelwal913
Copy link
Author

Looks like the build failure is caused by a Javadoc error:

16:49:16  [ERROR] /home/jenkins/agent/workspace/line-utility-steps-plugin_PR-180/src/main/java/org/jenkinsci/plugins/pipeline/utility/steps/AbstractFileCompressStep.java:132: error: invalid use of @return
16:49:16  [ERROR]      * @return the defaultExcludes boolean
16:49:16  [ERROR]        ^

Thanks for the pointer. Fixed it.

@@ -75,10 +75,13 @@ static class ZipItFileCallable extends AbstractFileCallable<Integer> {
final String exclude;
final boolean overwrite;

public ZipItFileCallable(String glob, String exclude, boolean overwrite) {
private boolean defaultExcludes = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making this field final would make it both consistent with the other fields in this class and easier to reason about (mutable state is generally harder to reason about than immutable state).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. can you review?

Comment on lines 25 to 28
<p>
The zip file should include defaultExcludes provided by ant java pattern.
By Default defaultExcludes param value will be true.
</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This documentation is grammatically confusing (the first sentence probably meant to say "Whether the zip file should […]") and also has incorrect capitalization. Suggest clarifying as follows:

<p>By default, the following exclusions are applied:</p>

<pre>**/*~
**/#*#
**/%*%
**/.#*
**/._*
**/.bzr
**/.bzr/**
**/.bzrignore
**/CVS
**/CVS/**
**/.cvsignore
**/.DS_Store
**/.git
**/.git/**
**/.gitattributes
**/.gitignore
**/.gitmodules
**/.hg
**/.hg/**
**/.hgignore
**/.hgsub
**/.hgsubstate
**/.hgtags
**/SCCS
**/SCCS/**
**/.svn
**/.svn/**
**/vssver.scc
</pre>

<p>Set this option to <code>false</code> if you do not want these default exclusions to be applied.</p>

Comment on lines 51 to 52
* <a href="https://ant.apache.org/manual/dirtasks.html#defaultexcludes" target="_blank">Ant style pattern</a>
* of files to disable default excludes from the archive.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect: this is a boolean, not a pattern.

Comment on lines 61 to 62
* <a href="https://ant.apache.org/manual/dirtasks.html#defaultexcludes" target="_blank">Ant style pattern</a>
* of files to disable default excludes from the archive.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect: this is a boolean, not a pattern.

@basil
Copy link
Member

basil commented Jan 13, 2023

It is only applies to zip files.

From my reading of the code, it appears the tar step uses the same Ant task and therefore the same default exclusions. If true, then it seems inconsistent to add this parameter to the zip step but not the tar step.

@ykhandelwal913
Copy link
Author

From my reading of the code, it appears the tar step uses the same Ant task and therefore the same default exclusions. If true, then it seems inconsistent to add this parameter to the zip step but not the tar step.

As this ticket was for zip step i added code only for that but i agree with your point and to have the same consistency in zip and tar, added the same in tarStep as well.

@ykhandelwal913
Copy link
Author

@basil can this be reviewed now. This feature is much needed for us to progress in our project. Hence the urgency.

Copy link
Member

@basil basil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good overall, but I think now that the scope of this PR extends to both the zip and the tar step, HTML documentation for the tar step needs to be added to match that of the zip step, along with a corresponding test for the tar step. Otherwise the change is inconsistent, applying some logic to one step but not the other.

Copy link
Member

@basil basil left a 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. Thanks for your contribution and for addressing feedback so quickly! In order to set expectations properly, I am not a maintainer of this plugin (though I am a Jenkins core maintainer), so I will be unable to merge your change. But @rsandell is a maintainer of this plugin, and I believe that the work we have done together has brought this PR closer to a state that can be approved by him (if not to the finish line!). Thanks again!

@ykhandelwal913
Copy link
Author

Looks good to me. Thanks for your contribution and for addressing feedback so quickly! In order to set expectations properly, I am not a maintainer of this plugin (though I am a Jenkins core maintainer), so I will be unable to merge your change. But @rsandell is a maintainer of this plugin, and I believe that the work we have done together has brought this PR closer to a state that can be approved by him (if not to the finish line!). Thanks again!

Thanks for the feedback and support provided.

@rsandell
Copy link
Member

Looks good, from what I can see you only need to fix the javadoc errors in the new code to make the build pass.

@ykhandelwal913
Copy link
Author

Looks good, from what I can see you only need to fix the javadoc errors in the new code to make the build pass.

Done

@ykhandelwal913
Copy link
Author

@rsandell can this be merged?

@rsandell rsandell changed the title JENKINS-63587: Allow disabling Ant default excludes in the zip step [JENKINS-63587] Allow disabling Ant default excludes in the zip step Jan 16, 2023
@rsandell rsandell merged commit f7fd56c into jenkinsci:master Jan 16, 2023
@ykhandelwal913
Copy link
Author

ykhandelwal913 commented Jan 17, 2023

@rsandell It didnot create a new release. Do i need to do anything from my side?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants