コンパイルされた.texファイル(.pdf)をGitlabのルートリポジトリにアップロードします。

コンパイルされた.texファイル(.pdf)をGitlabのルートリポジトリにアップロードします。

次の問題を解決するには、お手伝いが必要です。.texGitLabでドキュメントをコンパイルし、コンパイルされた.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"

ここを読んでください: https://docs.gitlab.com/ee/ci/variables/

おすすめ記事