如何在 Azure DevOps 中实现自动化的 Sphinx 文档生成,如果 TexLive 被冻结?

huangapple go评论86阅读模式
英文:

How should I have automatic sphinx documentation in Azure Devops if texlive is frozen?

问题

I am using an azure pipeline to automatically update pdf documentation within a repository. I can do this using sphinx and a makefile together with .rst files that can be tracked with git. I wanted to have a windows pipeline such that the same commands can be used if users want to run the makefile on their local computer. Therefore I have the following azure_pipeline.yml:

# 触发流水线,仅限于在主分支上的拉取请求(不允许在主分支上提交代码)
# 在Azure DevOps中,此触发应通过“构建验证策略”添加。此触发无法在此YAML中完成。
trigger:
- master

pool:
  vmImage: 'windows-latest'

# 在这里定义要使用的Python版本
strategy:
  matrix:
    Python39:
      python.version: '3.9'

# 使用之前定义的Python版本
steps:
- task: UsePythonVersion@0
  inputs:
    versionSpec: '$(python.version)'
  displayName: '使用Python $(python.version)'

# 安装sphinx的依赖项,使用pep517以使sklearn能正常工作
- script: |
        python -m pip install -r sphinx_requirements.txt
  displayName: '安装sphinx依赖项'

# 安装make以创建sphinx文档,这样可以在流水线中使用与本地计算机上的“make pdf”命令类似的方式
- script: |
    choco feature enable -n allowGlobalConfirmation
    echo 安装Make
    choco install -y make
    refreshenv    
  workingDirectory: docs/
  displayName: '安装make'

# 安装texlive,这是TeX排版系统的免费分发版
# 安装基本版本,其中包括文档中使用的所有包,这些包未包含在基本方案中
- script: |
    choco install -y texlive --params="'/InstallationPath:C:\ProgramData\chocolatey\lib\texlive /scheme:basic /extraPackages:cmap,fncychap,transparent,eso-pic,lipsum,footnotebackref,setspace,datetime,etoolbox,xcolor,sectsty,enumitem,epigraph,float,wrapfig,capt-of,framed,upquote,needspace,parskip,tabulary,varwidth,fancyvrb,titlesec,fmtcount,xkeyval,nextpage'"
    refreshenv    
  displayName: '安装texlive'

# 使用下载的miktex创建sphinx文档
# 请注意,如果我们使用miktex而不是texlive,我们需要设置PATH,以确保我们始终设置它。如果我们使用texlive,它将继续运行。
- script: |
    echo 创建PDF
    make pdf    
  workingDirectory: docs/
  displayName: '创建sphinx文档'

# 从中复制PDF文件
- task: CopyFiles@2
  displayName: '复制PDF文件'
  inputs:
    SourceFolder: '$(Pipeline.Workspace)'
    Contents: '**/Palantir.pdf'
    TargetFolder: '$(Build.ArtifactStagingDirectory)'
    flattenFolders: true

# 将文件发布到构建工件
- task: PublishBuildArtifacts@1
  displayName: '发布工件: PDF'
  inputs:
    ArtifactName: 带有发布说明的文档

上述部分一直工作正常。但是,我现在在“安装texlive”步骤中遇到以下错误:

错误:由于首选项变量“ErrorActionPreference”或通用参数设置为停止,所以运行的命令已停止:TeX Live 2022已冻结
texlive可以自动卸载。

我不完全理解这个错误,我应该做哪些更改才能使Azure流水线正常工作?

附注:我已经尝试了MikTex,但无法使其正常工作。

英文:

I am using an azure pipeline to automatically update pdf documentation within a repository. I can do this using sphinx and a makefile together with .rst files that can be tracked with git. I wanted to have a windows pipeline such that the same commands can be used if users want to run the makefile on their local computer. Therefore I have the following azure_pipeline.yml:

# Trigger the pipeline pull requests in master (commits are not allowed in master)
# In Azure devops this should be added using a 'build validation policy'. This trigger can not be done in this yaml
trigger:
- master
pool:
vmImage: 'windows-latest'
# Define here which python version will be used
strategy:
matrix:
Python39:
python.version: '3.9'
# Use python version defined before
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
displayName: 'Use Python $(python.version)'
# Install sphinx dependencies, use pep517 to get sklearn to work 
- script: |
python -m pip install -r sphinx_requirements.txt
displayName: 'Install sphinx dependencies'
# Install make to create the sphinx documentation, this way the pipeline can be used similar as locally using the 'make pdf' call in build.cmd
- script: |
choco feature enable -n allowGlobalConfirmation
echo Install Make
choco install -y make
refreshenv
workingDirectory: docs/
displayName: 'Install make'
# Install texlive, which is a free distribution of the TeX typesetting system
# Install the basic version with all the packages we used in the documentation that is not already included in the basic scheme
- script: |
choco install -y texlive --params="'/InstallationPath:C:\ProgramData\chocolatey\lib\texlive /scheme:basic /extraPackages:cmap,fncychap,transparent,eso-pic,lipsum,footnotebackref,setspace,datetime,etoolbox,xcolor,sectsty,enumitem,epigraph,float,wrapfig,capt-of,framed,upquote,needspace,parskip,tabulary,varwidth,fancyvrb,titlesec,fmtcount,xkeyval,nextpage'"
refreshenv
displayName: 'Install texlive'
# Create the sphinx documentation with miktex that is just downloaded
# Note, that if we are using miktex instead of texlive, we need to set the PATH, just to be sure we will always set it, if we are using texlive, it will just continue
- script: |
echo Create pdf
make pdf
workingDirectory: docs/
displayName: 'Create sphinx documentation'
# Copy pdf file from 
- task: CopyFiles@2
displayName: 'Copy pdf file'
inputs:
SourceFolder: '$(Pipeline.Workspace)'
Contents: '**/Palantir.pdf'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
flattenFolders: true
# Publish file to a build artifact
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: pdf'
inputs:
ArtifactName: Documentation with release notes

Above was always working. However, I got now the following error in 'Install texlive':

ERROR: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: TeX Live 2022 is frozen
texlive may be able to be automatically uninstalled.

I don't completely understand this error, what should I change to have a working azure pipeline?

PS: I have already tried MikTex instead of Texlive. But I was not able to get that to work.

答案1

得分: 1

YAML Script:-

# Starter pipeline

# Start with a minimal pipeline that you can customize to build and deploy your code.

# Add steps that build, run tests, deploy, and more:

# https://aka.ms/yaml

# Trigger the pipeline pull requests in master (commits are not allowed in master)

# In Azure devops this should be added using a 'build validation policy'. This trigger can not be done in this yaml

trigger:

- master

  

pool:

vmImage: 'windows-latest'

  

# Define here which python version will be used

strategy:

matrix:

Python39:

python.version: '3.9'

  

# Use python version defined before

steps:

- task: UsePythonVersion@0

inputs:

versionSpec: '$(python.version)'

displayName: 'Use Python $(python.version)'

  

- script: |

python -m pip install -r $(Build.SourcesDirectory)\sphinx_requirements.txt

displayName: 'Install sphinx dependencies'

  

# Install make to create the sphinx documentation, this way the pipeline can be used similar as locally using the 'make pdf' call in build.cmd

- script: |

- script: |

choco install -y texlive --params="'/InstallationPath:$(Build.SourcesDirectory)\texlive /scheme:basic /extraPackages:cmap,fncychap,transparent,eso-pic,lipsum,footnotebackref,setspace,datetime,etoolbox,xcolor,sectsty,enumitem,epigraph,float,wrapfig,capt-of,framed,upquote,needspace,parskip,tabulary,varwidth,fancyvrb,titlesec,fmtcount,xkeyval,nextpage'"

refreshenv

displayName: 'Install texlive'

workingDirectory: $(Build.SourcesDirectory)

  

# Copy pdf file from

- task: CopyFiles@2

displayName: 'Copy pdf file'

inputs:

SourceFolder: '$(Build.SourcesDirectory)'

Contents: '**/Palantir.pdf'

TargetFolder: '$(Build.ArtifactStagingDirectory)'

flattenFolders: true

  

# Publish file to a build artifact

- task: PublishBuildArtifacts@1

inputs:

PathtoPublish: '$(Build.SourcesDirectory)'

ArtifactName: 'Documentation with release notes'

Output:-

如何在 Azure DevOps 中实现自动化的 Sphinx 文档生成,如果 TexLive 被冻结?

如何在 Azure DevOps 中实现自动化的 Sphinx 文档生成,如果 TexLive 被冻结?

Published Artifact:-

如何在 Azure DevOps 中实现自动化的 Sphinx 文档生成,如果 TexLive 被冻结?

Reference:-

azure-docs/add-template-to-azure-pipelines.md at main · MicrosoftDocs/azure-docs · GitHub

英文:

I tried the below YAML script and the Tex live package was installed and the pipeline to copy task with publish artifact ran successfully, Refer below:-

YAML Script:-

# Starter pipeline

# Start with a minimal pipeline that you can customize to build and deploy your code.

# Add steps that build, run tests, deploy, and more:

# https://aka.ms/yaml

# Trigger the pipeline pull requests in master (commits are not allowed in master)

# In Azure devops this should be added using a 'build validation policy'. This trigger can not be done in this yaml

trigger:

- master

  

pool:

vmImage: 'windows-latest'

  

# Define here which python version will be used

strategy:

matrix:

Python39:

python.version: '3.9'

  

# Use python version defined before

steps:

- task: UsePythonVersion@0

inputs:

versionSpec: '$(python.version)'

displayName: 'Use Python $(python.version)'

  

- script: |

python -m pip install -r $(Build.SourcesDirectory)\sphinx_requirements.txt

displayName: 'Install sphinx dependencies'

  
  

# Install make to create the sphinx documentation, this way the pipeline can be used similar as locally using the 'make pdf' call in build.cmd

- script: |

- script: |

choco install -y texlive --params="'/InstallationPath:$(Build.SourcesDirectory)\texlive /scheme:basic /extraPackages:cmap,fncychap,transparent,eso-pic,lipsum,footnotebackref,setspace,datetime,etoolbox,xcolor,sectsty,enumitem,epigraph,float,wrapfig,capt-of,framed,upquote,needspace,parskip,tabulary,varwidth,fancyvrb,titlesec,fmtcount,xkeyval,nextpage'"

refreshenv

displayName: 'Install texlive'

workingDirectory: $(Build.SourcesDirectory)

  

# Copy pdf file from

- task: CopyFiles@2

displayName: 'Copy pdf file'

inputs:

SourceFolder: '$(Build.SourcesDirectory)'

Contents: '**/Palantir.pdf'

TargetFolder: '$(Build.ArtifactStagingDirectory)'

flattenFolders: true

  

# Publish file to a build artifact

- task: PublishBuildArtifacts@1

inputs:

PathtoPublish: '$(Build.SourcesDirectory)'

ArtifactName: 'Documentation with release notes'

Output:-

如何在 Azure DevOps 中实现自动化的 Sphinx 文档生成,如果 TexLive 被冻结?

如何在 Azure DevOps 中实现自动化的 Sphinx 文档生成,如果 TexLive 被冻结?

Published Artifact:-

如何在 Azure DevOps 中实现自动化的 Sphinx 文档生成,如果 TexLive 被冻结?

Reference:-

azure-docs/add-template-to-azure-pipelines.md at main · MicrosoftDocs/azure-docs · GitHub

huangapple
  • 本文由 发表于 2023年3月15日 19:17:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/75743978.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定