繁体   English   中英

Azure DevOps 从管道发送参数到 powershell

[英]Azure DevOps send parameters from pipeline to powershell

我试图在 inte.net 中找到一些信息。 但不幸的是我找不到任何信息。 我试图将管道参数从管道发送到 powershell 脚本

下面的管道:

parameters:
    - name: env
      displayName: Select Environment
      type: string
      default: development
    
stages:
- stage: test
  displayName: test var
  jobs:
  - job: PostgresSQL
    steps:
      - task: PowerShell@2
        inputs:
          filePath: '$(5ystem. DefaultWorkingDirectory)/test.psl'
          errorActionPreference: 'continue'
        enabled: true

我需要将${{ parameters.env }}发送到 powershell。我尝试了不同类型的定义参数,例如将变量发送到 powershell。但它不起作用。

如果有人可以帮助我并为此分享相关文档,我将非常高兴。

谢谢大家

第一种方法是使用“arguments”关键字提供 arguments(通过“param”在 PowerShell 中可用)

filePath: xyz
arguments: -input1 ${{ parameters.env }}

文档和示例 - https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/powershell-v2?view=azure-pipelines#call-powershell-script-with-multiple-arguments

第二种方法,您可以将 map 参数传递给使用“env”关键字提供给脚本的环境变量

env:
  input1: ${{ parameters.env }}

文档 - https://learn.microsoft.com/en-us/azure/devops/pipelines/process/tasks?view=azure-devops&tabs=yaml#environment-variables

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM