azure-devops - 如何将 Bash 或 PowerShell 脚本添加到 Azure DevOps 管道
问题描述
我对 CI 很陌生,正在试验 Azure DevOps。
我想在我的 CI 管道中使用自动化测试工具,该工具使用 Bash 脚本和在 CI 管道内运行的 PowerShell 脚本来触发测试工具。
如何将 Bash 或 PowerShell 脚本添加到 Azure DevOps 中的管道中,以便脚本运行并触发测试工具?
解决方案
您可以将内置的PowerShell / Bash任务添加到管道中。
您可以添加.ps1
或添加.sh
到您的存储库并在任务中指定脚本文件,或放入内联脚本。
如果您使用.yaml
构建,您可以通过以下方式添加它们:
# PowerShell
# Run a PowerShell script on Windows, macOS, or Linux.
- task: PowerShell@2
inputs:
#targetType: 'filePath' # Optional. Options: filePath, inline
#filePath: # Required when targetType == FilePath
#arguments: # Optional
#script: '# Write your powershell commands here.' # Required when targetType == Inline
#errorActionPreference: 'stop' # Optional. Options: stop, continue, silentlyContinue
#failOnStderr: false # Optional
#ignoreLASTEXITCODE: false # Optional
#pwsh: false # Optional
#workingDirectory: # Optional
# Bash
# Run a Bash script on macOS, Linux, or Windows
- task: Bash@3
inputs:
#targetType: 'filePath' # Optional. Options: filePath, inline
#filePath: # Required when targetType == FilePath
#arguments: # Optional
#script: '# Write your commands here# Use the environment variables input below to pass secret variables to this script' # Required when targetType == Inline
#workingDirectory: # Optional
#failOnStderr: false # Optional
#noProfile: true # Optional
#noRc: true # Optional
如果您使用可视化设计器,您可以通过以下方式添加任务:
推荐阅读
- cakephp - 如果是自引用的 belongsToMany 关联中的子项,则防止删除
- scala - 是否可以为伴随对象指定特征?
- python - Tensorflow 不使用 GPU,发现 xla_gpu 不是 gpu
- python - 检查混合类型列的值是否等于 0(使用 timedelta 和浮点数)
- python - Python 中的 Apriori 结果
- excel - 在 Excel 单元格中写入主题标签的问题
- javascript - 使用 onClick 事件渲染 JSX Switch Case
- ios - UITableView 中的 iOS 13 UISegmentedControl 缓存先前的选择
- php - 如何在 laravel 的 highchart bar consoletv/charts 包上显示数据标签
- sql - 如果日期是连续的,则查询并返回用户请求