我正在尝试在 Azure DevOps Repo 中为我的代码自动生成和更新文档。我已经配置了一个管道,以便在提交到 master 分支时运行 python 脚本。此脚本从存储库中的文件中提取相关信息并创建一个降价文件并将输出存储为 README.md
但是,当我运行管道时,什么也没有发生。作业注册为已完成,但 README.md 文件未更改。我没有出现错误或任何东西,所以不太确定出了什么问题,也许是权限问题。有人知道对此有什么解决办法吗?
管道代码:
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.8'
- script: |
python -m pip install --upgrade pip
pip install -r requirements.txt
python generate-documentation.py
displayName: 'Generate Documentation'
Python脚本:
import yaml
file = open('single-source.yaml')
documentation = yaml.load(file, Loader=yaml.FullLoader)
productdetails = documentation["product details"]
specifications = documentation["specifications"]
prerequisites = documentation["prerequisites"]
requiredinputs = documentation["required inputs"]
selfservice = documentation["self service"]
costsandcharging = documentation["costs and charging"]
f = open("README.md","w")
for x in productdetails.values():
f.write(x+"\n" )
f = open("README.md","a")
if "specifications" in documentation:
for x in specifications.values():
f.write(x+"\n")
if "prerequisites" in documentation:
for x in prerequisites.values():
f.write(x+"\n")
if "requiredinputs" in documentation:
for x in requiredinputs.values():
f.write(x+"\n")
if "selfservice" in documentation:
for x in selfservice.values():
f.write(x+"\n")
if "costsandcharging" in documentation:
for x in costsandcharging.values():
f.write(x)
f.close()