【问题标题】:How to add Bash or PowerShell script to Azure DevOps pipeline如何将 Bash 或 PowerShell 脚本添加到 Azure DevOps 管道
【发布时间】:2019-05-09 12:10:26
【问题描述】:

我是 CI 的新手,正在试验 Azure DevOps。

我想在我的 CI 管道中使用自动化测试工具,该工具使用 Bash 脚本和在 CI 管道内运行的 PowerShell 脚本来触发测试工具。

如何在 Azure DevOps 中将 Bash 或 PowerShell 脚本添加到我的管道中,以便脚本运行并触发测试工具?

【问题讨论】:

    标签: azure-devops continuous-integration azure-pipelines


    【解决方案1】:

    您可以将内置的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
    

    如果您使用可视化设计器,您可以通过以下方式添加任务:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-20
      • 1970-01-01
      • 2020-11-13
      • 2022-12-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-15
      • 1970-01-01
      相关资源
      最近更新 更多