azure devops steps.script vs cmdline@2/ bash@3

发布于 2025-01-31 01:13:36 字数 1061 浏览 2 评论 0 原文

步骤。目的尚不清楚。它仅允许执行内联脚本?我实际上想将文件与steps.script一起使用,而不是内联脚本。

我不能在Windows上使用cmdline@2,也不能在linux/unix上使用bash@3而不是stepsript。

speps.script的链接: https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/steps-script?view = azure-pipelines

cmdline@2: https> https:https:https://学习.microsoft.com/en-us/azure/devops/pipelines/tasks/tasks/commant-line?view = azure-devops& tabs& amp; yaml

bash@bash@3: https://learn.microsoft.com/en-en-en-us/ azure/devops/pipelines/tasks/bash/bash?view = azure-devops

steps.script purpose is NOT clear. It allows only Inline Scripts to be executed? I actually want to use file with steps.script instead of inline script.

Cannot i use CmdLine@2 on windows or Bash@3 on linux/Unix Instead of steps.script.

Link for steps.script: https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/steps-script?view=azure-pipelines

Link for CmdLine@2: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/command-line?view=azure-devops&tabs=yaml

Link for Bash@3: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/bash?view=azure-devops

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不气馁 2025-02-07 01:13:36

脚本步骤是YAML中的平台不可知论:

脚本步骤使用windows上的cmd.exe运行脚本,并在其他平台上敲击。

您还可以明确使用 pwsh: powerShell: bash:明确选择某个脚本类型。这些是相应任务的便利捷径,这是来自 powershell@2 文档:

PowerShell任务在YAML中还具有两个快捷方式:

   -  PowerShell:#Inline脚本
  WorkingDirectory:#
  DisplayName:#
  failOnstderr:#
  ErrorActionPreference:#
  警告:#
  信息重新回报:#
  verbosepreference:#
  debugpreference:#
  ignorelastexitCode:#
  env:#要添加的环境变量映射
 
  -pwsh:#inline脚本
  WorkingDirectory:#
  DisplayName:#
  failOnstderr:#
  ErrorActionPreference:#
  警告:#
  信息重新回报:#
  verbosepreference:#
  debugpreference:#
  ignorelastexitCode:#
  env:#要添加的环境变量映射
 

这两个快捷方式都解散为PowerShell@2任务。 PowerShell运行Windows PowerShell,并且只能在Windows代理上使用。 PWSH运行PowerShell Core,必须安装在代理或容器上。

其他YAML便利捷径也是如此。

基本上,您可以选择哪一个以及使用快捷方式或完整步骤名称。

The Script step is a platform agnostic step in YAML:

The script step runs a script using cmd.exe on Windows and Bash on other platforms.

You can also explicitly use pwsh: or powershell: or bash: to explicitly pick a certain script type. These are convenience shortcuts for the respective tasks, this is from the PowerShell@2 docs:

The PowerShell task also has two shortcuts in YAML:

- powershell:  # inline script
  workingDirectory:  #
  displayName:  #
  failOnStderr:  #
  errorActionPreference:  #
  warningPreference:  #
  informationPreference:  #
  verbosePreference:  #
  debugPreference:  #
  ignoreLASTEXITCODE:  #
  env:  # mapping of environment variables to add
- pwsh:  # inline script
  workingDirectory:  #
  displayName:  #
  failOnStderr:  #
  errorActionPreference:  #
  warningPreference:  #
  informationPreference:  #
  verbosePreference:  #
  debugPreference:  #
  ignoreLASTEXITCODE:  #
  env:  # mapping of environment variables to add

Both of these shortcuts resolve to the PowerShell@2 task. powershell runs Windows PowerShell and will only work on a Windows agent. pwsh runs PowerShell Core, which must be installed on the agent or container.

The same applies to the other YAML convenience shortcuts.

It's basically up to your preference which one you pick and whether you use the shortcut or the full step name.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文