[英]Azure DevOps send parameters from pipeline to powershell
I tried to find some information in inte.net.我试图在 inte.net 中找到一些信息。 But unfortunately I could not found any information.但不幸的是我找不到任何信息。 Im trying to send pipeline parameters from pipeline into powershell script我试图将管道参数从管道发送到 powershell 脚本
pipeline below:下面的管道:
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
I need to send ${{ parameters.env }} to powershell. I tried different type of define param like a variable into powershell. but it does not work.我需要将${{ parameters.env }}发送到 powershell。我尝试了不同类型的定义参数,例如将变量发送到 powershell。但它不起作用。
I would be very happy if anybody can help me and share relevant documentation for that.如果有人可以帮助我并为此分享相关文档,我将非常高兴。
Thanks all谢谢大家
First approach is to provide arguments using 'arguments' keyword (available in PowerShell by 'param')第一种方法是使用“arguments”关键字提供 arguments(通过“param”在 PowerShell 中可用)
filePath: xyz
arguments: -input1 ${{ parameters.env }}
documentation and example - https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/powershell-v2?view=azure-pipelines#call-powershell-script-with-multiple-arguments文档和示例 - https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/powershell-v2?view=azure-pipelines#call-powershell-script-with-multiple-arguments
Second approach you can map parameters to environment variables provided to script using 'env' keyword第二种方法,您可以将 map 参数传递给使用“env”关键字提供给脚本的环境变量
env:
input1: ${{ parameters.env }}
documentation - https://learn.microsoft.com/en-us/azure/devops/pipelines/process/tasks?view=azure-devops&tabs=yaml#environment-variables文档 - 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.