Skip to content
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

allow markdown and html files for documentation of library steps #117

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mawinter69
Copy link
Contributor

It is now possible to use also markdown (extension .md) and html files (extension .html) to document library steps.
The corresponding formatters are used respectively (markdown or owasp) for them and the globally configured formatter is ignored.
.txt files are still accepted and will use the globally configured formatter as before.

The current approach with the txt files has the problem that the content must fit the formatter that is globally configured. When a pipeline library is generic enough to be used on many Jenkins instances the documentation might be broken.
As Markdown allows to easily write the docs this should be the new default I think (requires to adjust https://www.jenkins.io/doc/book/pipeline/shared-libraries/)
The snippet is wrapped in a div so we can apply a different styling. The default Jenkins styling doesn't look so good for markdown files at least (no margin before <hx> and big margin afterwards)

Testing done

Manual testing
added a unit test (for markdown)

Submitter checklist

Preview Give feedback

the current approach with the txt files has the problem that the content
must fit the formatter that is globally configured. When a pipeline
library is generic enough to be used on many Jenkins instances the
documentation might be broken.
As Markdown allows to easily write the docs this should be the new
default.
The snippet is wrapped in a div so we can apply a different styling. The
default Jenkins styling doesn't look so good for markdown files at least
(no margin before `<hx>` and big margin afterwards)
@mawinter69 mawinter69 requested a review from a team as a code owner March 27, 2024 18:12
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>markdown-formatter</artifactId>
<version>95.v17a_965e696ee</version>
Copy link
Member

Choose a reason for hiding this comment

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

Not in bom? I would omit this one and stick to the more standard antisamy-markup-formatter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The antisamy-markup-formatter can only sanitize html and is not able to convert markdown to html. So without this dependency it is not possible to use markdown files for documentation (and I think we should avoid directly setting a dependency to the commonmark java library when we have a plugin that provides it). Maybe we can add it to the bom

Copy link
Member

Choose a reason for hiding this comment

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

without this dependency it is not possible to use markdown files for documentation

Right, I was proposing to just drop that feature.

Maybe we can add it to the bom

You could. I have no idea how well supported this plugin is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mark Waite is maintaining the plugin, so should be well supported

Copy link
Contributor

Choose a reason for hiding this comment

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

I really like the markdown formatter plugin and plan to continue maintaining it. I have it installed on my local Jenkins instances and use it regularly

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm happy to submit the plugin to the BOM. It has less than 1000 installations but it is very helpful and has worked well in all the cases where I've used it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Submitted for possible inclusion in the plugin bill of materials:

Copy link
Contributor

Choose a reason for hiding this comment

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

The markdown formatter plugin is included in plugin bill of materials 2961.v1f472390972e (April 8, 2024).

</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>antisamy-markup-formatter</artifactId>
Copy link
Member

Choose a reason for hiding this comment

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

Needs to be optional, and then use @OptionalExtension.

@jglick jglick requested a review from MarkEWaite March 27, 2024 20:34
MarkEWaite added a commit to MarkEWaite/bom that referenced this pull request Apr 3, 2024
Proposed wider use to document Pipeline shared libraries

jenkinsci/pipeline-groovy-lib-plugin#117

Has 860 installations with that number increasing steadily.

https://plugins.jenkins.io/pegdown-formatter/ should be deprecated. It
was last released 12 years ago.  It has a known security vulnerability.
It has no maintainer.  It has a health score of 57/100.  Still has over
1000 installations, but many of those installations could use markdown
formatter.
@MarkEWaite
Copy link
Contributor

MarkEWaite commented Apr 3, 2024

@mawinter69 I'm a little embarrassed to admit it, but I don't know how to see the documentation for a Pipeline library from inside Jenkins. I've installed an incremental build in my development system and have added markdown formatting to a library that I use, but I don't know how to see that from inside Jenkins. Can you give me guidance?

@mawinter69
Copy link
Contributor Author

It's documented here:
https://www.jenkins.io/doc/book/pipeline/shared-libraries/
Basically you need to run a job once that uses the library then you can see on the jobs pypeline syntax -> Global variable reference the steps

Copy link
Contributor

@MarkEWaite MarkEWaite left a comment

Choose a reason for hiding this comment

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

I've confirmed this works with my Jenkins controller that includes the build of this pull request. I've converted the Pipeline documentation to markdown in my Pipeline shared library . Works great.

I've proposed to include the markdown formatter in the plugin bill of materials and have deprecated the pegdown formatter plugin (last released 12 years ago, known vulnerability, using a deprecated markdown library).

The Jenkins infra team would need to be persuaded to install the markdown formatter plugin on ci.jenkins.io before my documentation updates could be used there.

basil pushed a commit to jenkinsci/bom that referenced this pull request Apr 3, 2024
Proposed wider use to document Pipeline shared libraries

jenkinsci/pipeline-groovy-lib-plugin#117

Has 860 installations with that number increasing steadily.

https://plugins.jenkins.io/pegdown-formatter/ should be deprecated. It
was last released 12 years ago.  It has a known security vulnerability.
It has no maintainer.  It has a health score of 57/100.  Still has over
1000 installations, but many of those installations could use markdown
formatter.
@MarkEWaite
Copy link
Contributor

I've started a discussion with the infra team in Gitter and have created a help desk ticket for further review of the markdown formatter plugin and for more discussion. The ci.jenkins.io instance is a large scale instance and the infrastructure team needs to be sure that new additions do not disrupt its primary mission. The related help desk ticket is:

@MarkEWaite
Copy link
Contributor

@mawinter69 would you be willing to merge the master branch into this pull request so that I can continue using this in my test environment?

@mawinter69
Copy link
Contributor Author

btw the way the markdown formatter plugin is used here is more in the form of a library plugin. Same applies to the owasp html formatter. The usage here is independent from what is configured globally in a Jenkins instance for formatting job/run descriptions.

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

Successfully merging this pull request may close these issues.

3 participants