gpt4 book ai didi

Azure DevOps 发布管道 Azure CLI Powershell 任务找不到 powershell

转载 作者:行者123 更新时间:2023-12-03 04:01:59 31 4
gpt4 key购买 nike

使用:池:Azure Pipelines·代理:托管代理

第一个版本仅包含 2 个任务:

  1. 写入“Hello world”的 Powershell 内联脚本
  2. Azure 订阅内联脚本上的 Powershell 写入“Hello world” enter image description here

效果很好。

添加其他任务后:

  1. 执行我们的 PowerShell 脚本

  2. .4 部署到 Kubernetes 任务。 enter image description here

使用system.debug创建版本,但第一个任务失败并出现错误:

2020-05-20T06:57:10.3710666Z ##[error]The term 'powershell.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Executing with system.debug gave this output:

2020-05-20T07:15:13.9833585Z ##[debug]Evaluating condition for step: 'Hello World'
2020-05-20T07:15:13.9843565Z ##[debug]Evaluating: succeeded()
2020-05-20T07:15:13.9844512Z ##[debug]Evaluating succeeded:
2020-05-20T07:15:13.9845838Z ##[debug]=> True
2020-05-20T07:15:13.9846542Z ##[debug]Result: True
2020-05-20T07:15:13.9847415Z ##[section]Starting: Hello World
2020-05-20T07:15:14.0314856Z ==============================================================================
2020-05-20T07:15:14.0315650Z Task : PowerShell
2020-05-20T07:15:14.0317519Z Description : Run a PowerShell script on Linux, macOS, or Windows
2020-05-20T07:15:14.0317953Z Version : 2.169.0
2020-05-20T07:15:14.0318548Z Author : Microsoft Corporation
2020-05-20T07:15:14.0319259Z Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
2020-05-20T07:15:14.0319792Z ==============================================================================
2020-05-20T07:15:15.8622679Z ##[debug]VstsTaskSdk 0.11.0 commit 7ff27a3e0bdd6f7b06690ae5f5b63cb84d0f23f4
2020-05-20T07:15:16.0680294Z ##[debug]Entering D:\a\_tasks\PowerShell_e213ff0f-5d5c-4791-802d-52ea3e7be1f1\2.169.0\powershell.ps1.
2020-05-20T07:15:16.0782094Z ##[debug]Loading resource strings from: D:\a\_tasks\PowerShell_e213ff0f-5d5c-4791-802d-52ea3e7be1f1\2.169.0\task.json
2020-05-20T07:15:16.1340432Z ##[debug]Loaded 11 strings.
2020-05-20T07:15:16.1343861Z ##[debug]SYSTEM_CULTURE: 'en-US'
2020-05-20T07:15:16.1345219Z ##[debug]Loading resource strings from: D:\a\_tasks\PowerShell_e213ff0f-5d5c-4791-802d-52ea3e7be1f1\2.169.0\Strings\resources.resjson\en-US\resources.resjson
2020-05-20T07:15:16.1597086Z ##[debug]Loaded 11 strings.
2020-05-20T07:15:16.1959084Z ##[debug]INPUT_ERRORACTIONPREFERENCE: 'stop'
2020-05-20T07:15:16.2027000Z ##[debug]INPUT_FAILONSTDERR: 'false'
2020-05-20T07:15:16.2028272Z ##[debug] Converted to bool: False
2020-05-20T07:15:16.2041964Z ##[debug]INPUT_IGNORELASTEXITCODE: 'false'
2020-05-20T07:15:16.2056755Z ##[debug] Converted to bool: False
2020-05-20T07:15:16.2081737Z ##[debug]INPUT_PWSH: 'false'
2020-05-20T07:15:16.2100091Z ##[debug] Converted to bool: False
2020-05-20T07:15:16.2122826Z ##[debug]INPUT_WORKINGDIRECTORY: 'D:\a\r1\a'
2020-05-20T07:15:16.2247526Z ##[debug]Asserting container path exists: 'D:\a\r1\a'
2020-05-20T07:15:16.2273044Z ##[debug]INPUT_TARGETTYPE: 'inline'
2020-05-20T07:15:16.2307533Z ##[debug]INPUT_SCRIPT: '# Write your PowerShell commands here.
2020-05-20T07:15:16.2320023Z ##[debug]
2020-05-20T07:15:16.2331579Z ##[debug]Write-Host "Hello World"'
2020-05-20T07:15:16.2375904Z Generating script.
2020-05-20T07:15:16.2515233Z ##[debug]AGENT_VERSION: '2.168.2'
2020-05-20T07:15:16.2594226Z ##[debug]AGENT_TEMPDIRECTORY: 'D:\a\_temp'
2020-05-20T07:15:16.2614777Z ##[debug]Asserting container path exists: 'D:\a\_temp'
2020-05-20T07:15:27.6754436Z ##[debug]Leaving D:\a\_tasks\PowerShell_e213ff0f-5d5c-4791-802d-52ea3e7be1f1\2.169.0\powershell.ps1.
2020-05-20T07:15:27.9496049Z ##[debug]Caught exception from task script.
2020-05-20T07:15:27.9529115Z ##[debug]Error record:
2020-05-20T07:15:28.0379597Z ##[debug]The term 'powershell.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
2020-05-20T07:15:28.0395647Z ##[debug] + CategoryInfo : ObjectNotFound: (powershell.exe:String) [], CommandNotFoundException
2020-05-20T07:15:28.0402331Z ##[debug] + FullyQualifiedErrorId : CommandNotFoundException
2020-05-20T07:15:28.0412871Z ##[debug]
2020-05-20T07:15:28.0433105Z ##[debug]Script stack trace:
2020-05-20T07:15:28.0479363Z ##[debug]
2020-05-20T07:15:28.1031586Z ##[debug]Exception:
2020-05-20T07:15:28.1168338Z ##[debug]System.Management.Automation.CommandNotFoundException: The term 'powershell.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
2020-05-20T07:15:28.1325804Z ##[error]The term 'powershell.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
2020-05-20T07:15:28.1338779Z ##[debug]Processed: ##vso[task.logissue type=error]The term 'powershell.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
2020-05-20T07:15:28.1347561Z ##[debug]Processed: ##vso[task.complete result=Failed]
2020-05-20T07:15:28.2164053Z ##[section]Finishing: Hello World

最佳答案

注意。

不要在 Azure DevOps 管道中命名变量 path,因为它会重写环境变量 PATH。重命名我的变量后,它再次工作并能够找到所有工具。在 MS 文档中没有提及,因此我为他们创建了一张票证。

关于Azure DevOps 发布管道 Azure CLI Powershell 任务找不到 powershell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61909394/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com