我有一个将Azure boards工作项导出到csv文件的管道
过程如下:
从上次成功的管道运行下载构建工件(csv文件和timestamp.txt)
运行Python脚本以查询自上次成功运行管道以来更新的工作项(上次导出时间为timestamp.txt)。如果有更新的工作项,则使用这些工作项更新csv文件,更新timestamp.txt并使用0退出程序。如果未找到更新的工作项,请使用非零值退出程序
将更新或“未更新”的csv文件和timestamp.txt发布为构建工件
将更新的csv文件上载到SharePoint网站
我想要实现的是:
无论是否更新csv文件,管道运行都应以成功结束
我需要定义一个bool变量,它可以根据Python脚本的退出代码进行设置(也可以直接在Python脚本中进行设置)
使用该bool变量作为上载到SharePoint任务的条件
如何创建YAML文件来实现这一点?谢谢
亚马尔:
# - master
trigger: none
schedules:
- cron: "0 */12 * * 1,2,3,4,5"
displayName: Hourly Azure All WorkItems Export
branches:
include:
- master
always: true
pool: 'Windows-VS2017DEV'
steps:
# - task: InstallPython@1
# inputs:
# version: 'python'
- task: UsePythonVersion@0
inputs:
versionSpec: '3.x'
addToPath: true
architecture: 'x64'
- task: DownloadBuildArtifacts@0
inputs:
buildType: 'specific'
project: 'XXX'
pipeline: 'xxx'
buildVersionToDownload: 'latest'
downloadType: 'single'
artifactName: 'Azure_Reporting'
downloadPath: '$(System.DefaultWorkingDirectory)'
- task: PythonScript@0
inputs:
scriptSource: 'filePath'
scriptPath: 'Python/azure_workitems.py'
arguments: '$(azure_workitems_option)'
- task: CopyFiles@2
inputs:
contents: |
*csv
timestamp.txt
targetFolder: $(Build.ArtifactStagingDirectory)
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: $(Build.ArtifactStagingDirectory)
artifactName: Azure_Reporting
- task: UploadFilesToSPDocLib@1
inputs:
spUrl: 'https://XXXX.sharepoint.com/sites/XXXX'
targetFolder: 'Shared%20Documents/Status%20dashboards/Azure_Reporting'
login: 'XXXXX@XXXXXX.com'
password: $(XXX.Credential)
filesToUpload: ' $(Build.ArtifactStagingDirectory)/azure_workitems.csv'
在python脚本中,可以根据逻辑(而不是退出代码)为新变量赋值
例如,如果代码执行了他应该执行的操作,并且您希望运行上载到SharePoint任务,请添加以下logging command:
并在上载到SharePoint任务中添加a custom condition:
相关问题 更多 >
编程相关推荐