我需要您的帮助来解决以下问题。我正在尝试.tex
在 GitLab 中编译文档并将编译后的.pdf
文件放入根存储库中。我创建了一个.gitlab-ci.yml
具有以下配置的文件:
# Use the latest version of the TeX Live Docker image
image: texlive/texlive:latest
# Define a single stage named "build"
stages:
- build
# Configuration for the "build" stage
build:
stage: build
# Specify the events that trigger the pipeline
only:
- push
# Specify the commands to be executed in the pipeline
script:
- filename="main"
- echo "Running latexmk with lualatex"
- latexmk -pdf -pdflatex="lualatex %O %S" "$filename.tex"
- echo "Moving .pdf file to root directory"
- mv "$filename.pdf" ../
- echo "Listing contents of root directory"
- ls ../
该log
文件告诉我以下内容
Latexmk: All targets () are up-to-date
$ echo "Moving .pdf file to root directory"
Moving .pdf file to root directory
$ mv "$filename.pdf" ../
$ echo "Listing contents of root directory"
Listing contents of root directory
$ ls ../
PhD
PhD.tmp
main.pdf
Cleaning up project directory and file based variables
Job succeeded
但是,当我访问我的存储库时,我没有发现任何main.pdf
文件已加载。我怎么解决这个问题?有什么我不明白的吗?
答案1
在日志中您应该看到这一行
$ mv "$filename.pdf" ../
这意味着您的变量没有扩展。
在gitlab的yaml语法中,需要定义变量:
job:
variables:
var1: "apple"
var2: "orange"
所以你的脚本应该是
# Configuration for the "build" stage
build:
stage: build
# Specify the events that trigger the pipeline
only:
- push
variables:
filename: "main"
# Specify the commands to be executed in the pipeline
script:
- echo "Running latexmk with lualatex"
- latexmk -pdf -pdflatex="lualatex %O %S" "$filename.tex"