Using Gitlab environment variables in the generated asciidoc file?

Good day, wondering if anyone can successfully use a variable set with the builder in a generated asciidoc file? I’m reading the docs currently to try to find an answer but nothing so far. I see that the asciidoc has variables already in it but they’re local to the file. I’m trying to pass some author info of mine to the asciidoc generator (I think that’s the right name for it). Basically when I view my book.pdf file, wherever I set the AUTHOR variable in the adoc file it should be my name instead of the {AUTHOR} in it now.

Any help would be greatly appreciated, thanks!


Could you inject the attributes before building? e.g.

echo ":AUTHOR: $AUTHOR" > attributes
cat attributes document > document-with-attributes

I haven’t used asciidoc, so apologies if there’s an easier way.


No worries at all, I’ll take a look see if that works. I’m guessing I would add the code to the adoc file? My apologies for being so new to this as well.

I was thinking the code would go in the CI configuration, or in a build script, or even in before_script. Again, I haven’t used asciidoc and I don’t even know how it builds the output from the source, so you’re already ahead of me on this one! :slight_smile:

1 Like

I hear you and appreciate the help.

Still curious how I would add variable inside that Asciidoc? I know it goes between curly braces {} but {AUTHOR} doesn’t work when making that .adoc file.

I was looking at this: AsciiDoc Recommended Practices | Asciidoctor

1 Like

Yeah I saw that earlier but it only covers setting variables in the asciidoc itself, not grabbing the one that’s availabe from the Gitlab builder.