I'd like to generate a PDF from an .adoc
file with asciidoctor using
asciidoctor-pdf Doku.adoc
How can I print the current git sha1-hash into the PDF?
asciidoctor-pdf -acommitHash=$(git rev-parse HEAD) Doku.adoc
You can now use the document attribute commitHash
within your document by writing:
{commitHash}
Use ifdef
to test if the variable is set.
ifdef::commitHash[]
{commitHash}
endif::[]
You can also define a default as fallback if no attribute is defined from the CLI
:commit: Unknown
Version: {commit}
The command line -a
will override the document internal declaration.